-
-
We're sorry, but something went wrong.
-
-
If you are the application owner check the logs for more information.
-
-
-
diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png
deleted file mode 100644
index e69de29..0000000
diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png
deleted file mode 100644
index e69de29..0000000
diff --git a/public/favicon.ico b/public/favicon.ico
deleted file mode 100644
index e69de29..0000000
diff --git a/public/robots.txt b/public/robots.txt
deleted file mode 100644
index c19f78a..0000000
--- a/public/robots.txt
+++ /dev/null
@@ -1 +0,0 @@
-# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
diff --git a/server.go b/server.go
new file mode 100644
index 0000000..f7f298e
--- /dev/null
+++ b/server.go
@@ -0,0 +1,74 @@
+package main
+
+import (
+ "net/http"
+
+ "git.postblue.info/chris/alaska/models"
+ "github.com/gin-gonic/contrib/static"
+ "github.com/gin-gonic/gin"
+ "github.com/jinzhu/gorm"
+ _ "github.com/jinzhu/gorm/dialects/sqlite"
+ "github.com/prometheus/common/log"
+)
+
+func main() {
+ // database
+ db, err := gorm.Open("sqlite3", "certs.db")
+ if err != nil {
+ log.Fatal(err)
+ }
+ db.AutoMigrate(&models.Certificate{})
+ defer db.Close()
+
+ // router
+ router := gin.Default()
+ router.Use(static.Serve("/", static.LocalFile("./views", true)))
+ api := router.Group("/api")
+ {
+ api.GET("/", func(c *gin.Context) {
+ c.JSON(http.StatusOK, gin.H{
+ "message": "pong",
+ })
+ })
+ }
+ api.GET("/certs", CertHandler)
+ api.GET("/certs/:name", GetCert)
+ router.Run(":3000")
+}
+
+func getCerts() []models.Certificate {
+ db, err := gorm.Open("sqlite3", "certs.db")
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer db.Close()
+ res := []models.Certificate{}
+ if err := db.Limit(100).Find(&res).Error; err != nil {
+ log.Error(err)
+ }
+ return res
+}
+
+func searchCert(search string) []models.Certificate {
+ db, err := gorm.Open("sqlite3", "certs.db")
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer db.Close()
+ res := []models.Certificate{}
+ if err := db.Where(&models.Certificate{CN: search}).Or(&models.Certificate{Fingerprint: search}).Find(&res).Error; err != nil {
+ log.Warn(err)
+ }
+ return res
+}
+
+func CertHandler(c *gin.Context) {
+ getCerts()
+ c.Header("Content-Type", "application/json")
+ c.JSON(http.StatusOK, getCerts())
+}
+
+func GetCert(c *gin.Context) {
+ c.Header("Content-Type", "application/json")
+ c.JSON(http.StatusOK, searchCert(c.Param("name")))
+}
diff --git a/storage/.keep b/storage/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
deleted file mode 100644
index d19212a..0000000
--- a/test/application_system_test_case.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require "test_helper"
-
-class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
- driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
-end
diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb
deleted file mode 100644
index 800405f..0000000
--- a/test/channels/application_cable/connection_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require "test_helper"
-
-class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
- # test "connects with cookies" do
- # cookies.signed[:user_id] = 42
- #
- # connect
- #
- # assert_equal connection.user_id, "42"
- # end
-end
diff --git a/test/controllers/.keep b/test/controllers/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/fixtures/.keep b/test/fixtures/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/helpers/.keep b/test/helpers/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/integration/.keep b/test/integration/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/mailers/.keep b/test/mailers/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/models/.keep b/test/models/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/system/.keep b/test/system/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/test/test_helper.rb b/test/test_helper.rb
deleted file mode 100644
index d5300f8..0000000
--- a/test/test_helper.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-ENV['RAILS_ENV'] ||= 'test'
-require_relative '../config/environment'
-require 'rails/test_help'
-
-class ActiveSupport::TestCase
- # Run tests in parallel with specified workers
- parallelize(workers: :number_of_processors)
-
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
- fixtures :all
-
- # Add more helper methods to be used by all tests here...
-end
diff --git a/tmp/.keep b/tmp/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/tmp/pids/.keep b/tmp/pids/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/vendor/.keep b/vendor/.keep
deleted file mode 100644
index e69de29..0000000
diff --git a/views/index.html b/views/index.html
new file mode 100644
index 0000000..ffc4019
--- /dev/null
+++ b/views/index.html
@@ -0,0 +1,21 @@
+
+
+
+