| 1 | package certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/ |
| 2 | |
| 3 | // The certstream package provides the main entry point for the certstream-server-go application. |
| 4 | // It initializes the webserver and the watcher for the certificate transparency logs. |
| 5 | // It also handles signals for graceful shutdown of the server. |
| 6 | |
| 7 | import ( |
| 8 | "logscip-go gomod github.com/golang/go/src go1.25.0 log/" |
| 9 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 10 | "os/signalscip-go gomod github.com/golang/go/src go1.25.0 `os/signal`/" |
| 11 | "syscallscip-go gomod github.com/golang/go/src go1.25.0 syscall/" |
| 12 | |
| 13 | "github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparencyscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/" |
| 14 | "github.com/d-Rickyy-b/certstream-server-go/internal/configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/" |
| 15 | "github.com/d-Rickyy-b/certstream-server-go/internal/metricsscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/metrics`/" |
| 16 | "github.com/d-Rickyy-b/certstream-server-go/internal/webscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/" |
| 17 | ) |
| 18 | |
| 19 | type Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream# struct { |
| 20 | webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#webserver. *webscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/.WebServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer# |
| 21 | metricsServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#metricsServer. *webscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/.WebServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer# |
| 22 | watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher. *certificatetransparencyscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/.Watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/Watcher# |
| 23 | configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config. configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/.Configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config# |
| 24 | } |
| 25 | |
| 26 | func NewRawCertstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/NewRawCertstream().(config configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/.Configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#) *Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream# { |
| 27 | cs := Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#{} |
| 28 | cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config. = config |
| 29 | |
| 30 | return &cs |
| 31 | } |
| 32 | |
| 33 | // NewCertstreamServer creates a new Certstream server from a config struct. |
| 34 | func NewCertstreamServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/NewCertstreamServer().(config configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/.Configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#) (*Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#, error) { |
| 35 | cs := Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#{} |
| 36 | cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config. = config |
| 37 | |
| 38 | // Initialize the webserver used for the websocket server |
| 39 | webserver := webscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/.NewWebsocketServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/NewWebsocketServer().(config.Webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Webserver..ListenAddrscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenAddr., config.Webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Webserver..ListenPortscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenPort., config.Webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Webserver..CertPathscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#CertPath., config.Webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Webserver..CertKeyPathscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#CertKeyPath.) |
| 40 | cs.webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#webserver. = webserver |
| 41 | |
| 42 | // Setup metrics server |
| 43 | cs.setupMetricsscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#setupMetrics().(webserver) |
| 44 | |
| 45 | return &cs, nil |
| 46 | } |
| 47 | |
| 48 | // NewCertstreamFromConfigFile creates a new Certstream server from a config file. |
| 49 | func NewCertstreamFromConfigFilescip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/NewCertstreamFromConfigFile().(configPath string) (*Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#, error) { |
| 50 | conf, err := configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/.ReadConfigscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ReadConfig().(configPath) |
| 51 | if err != nil { |
| 52 | return nil, err |
| 53 | } |
| 54 | |
| 55 | return NewCertstreamServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/NewCertstreamServer().(conf) |
| 56 | } |
| 57 | |
| 58 | // setupMetrics configures the webserver to handle prometheus metrics according to the config. |
| 59 | func (cs *Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#) setupMetricsscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#setupMetrics().(webserver *webscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/.WebServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer#) { |
| 60 | if cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..Enabledscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#$anon_e58a7fc537e999a3#Enabled. { |
| 61 | // If prometheus is enabled, and interface is either unconfigured or same as webserver config, use existing webserver |
| 62 | if (cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..ListenAddrscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenAddr. == "" || cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..ListenAddrscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenAddr. == cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Webserver..ListenAddrscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenAddr.) && |
| 63 | (cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..ListenPortscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenPort. == 0 || cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..ListenPortscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenPort. == cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Webserver..ListenPortscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenPort.) { |
| 64 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printlnscip-go gomod github.com/golang/go/src go1.25.0 log/Println().("Starting prometheus server on same interface as webserver") |
| 65 | webserver.RegisterPrometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer#RegisterPrometheus().(cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..MetricsURLscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#$anon_e58a7fc537e999a3#MetricsURL., metricsscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/metrics`/.Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/metrics`/Prometheus..Writescip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/metrics`/PrometheusExporter#Write().) |
| 66 | } else { |
| 67 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printlnscip-go gomod github.com/golang/go/src go1.25.0 log/Println().("Starting prometheus server on new interface") |
| 68 | cs.metricsServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#metricsServer. = webscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/.NewMetricsServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/NewMetricsServer().(cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..ListenAddrscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenAddr., cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..ListenPortscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#ListenPort., cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..CertPathscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#CertPath., cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..CertKeyPathscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/ServerConfig#CertKeyPath.) |
| 69 | cs.metricsServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#metricsServer..RegisterPrometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer#RegisterPrometheus().(cs.configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#config..Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#Prometheus..MetricsURLscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Config#$anon_e58a7fc537e999a3#MetricsURL., metricsscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/metrics`/.Prometheusscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/metrics`/Prometheus..Writescip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/metrics`/PrometheusExporter#Write().) |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // Start starts the webserver and the watcher. |
| 75 | // This is a blocking function that will run until the server is stopped. |
| 76 | func (cs *Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#) Startscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#Start().() { |
| 77 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().("Starting certstream-server-go v%s\n", configscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/.Versionscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/config`/Version.) |
| 78 | |
| 79 | // handle signals in a separate goroutine |
| 80 | signals := make(chan osscip-go gomod github.com/golang/go/src go1.25.0 os/.Signalscip-go gomod github.com/golang/go/src go1.25.0 os/Signal#, 1) |
| 81 | signalscip-go gomod github.com/golang/go/src go1.25.0 `os/signal`/.Notifyscip-go gomod github.com/golang/go/src go1.25.0 `os/signal`/Notify().(signals, syscallscip-go gomod github.com/golang/go/src go1.25.0 syscall/.SIGINTscip-go gomod github.com/golang/go/src go1.25.0 syscall/SIGINT., syscallscip-go gomod github.com/golang/go/src go1.25.0 syscall/.SIGTERMscip-go gomod github.com/golang/go/src go1.25.0 syscall/SIGTERM.) |
| 82 | go signalHandlerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/signalHandler().(signals, cs.Stopscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#Stop().) |
| 83 | |
| 84 | // If there is no watcher initialized, create a new one |
| 85 | if cs.watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher. == nil { |
| 86 | cs.watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher. = &certificatetransparencyscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/.Watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/Watcher#{} |
| 87 | } |
| 88 | |
| 89 | // Start webserver and metrics server |
| 90 | if cs.webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#webserver. == nil { |
| 91 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Fatallnscip-go gomod github.com/golang/go/src go1.25.0 log/Fatalln().("Webserver not initialized! Exiting...") |
| 92 | } |
| 93 | |
| 94 | go cs.webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#webserver..Startscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer#Start().() |
| 95 | |
| 96 | if cs.metricsServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#metricsServer. != nil { |
| 97 | go cs.metricsServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#metricsServer..Startscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer#Start().() |
| 98 | } |
| 99 | |
| 100 | // Start the watcher - this is a blocking function |
| 101 | cs.watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher..Startscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/Watcher#Start().() |
| 102 | } |
| 103 | |
| 104 | // Stop stops the watcher and the webserver. |
| 105 | func (cs *Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#) Stopscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#Stop().() { |
| 106 | if cs.watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher. != nil { |
| 107 | cs.watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher..Stopscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/Watcher#Stop().() |
| 108 | } |
| 109 | |
| 110 | if cs.webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#webserver. != nil { |
| 111 | cs.webserverscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#webserver..Stopscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer#Stop().() |
| 112 | } |
| 113 | |
| 114 | if cs.metricsServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#metricsServer. != nil { |
| 115 | cs.metricsServerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#metricsServer..Stopscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/web`/WebServer#Stop().() |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | // CreateIndexFile creates the index file for the certificate transparency logs. |
| 120 | // It gets only called when the CLI flag --create-index-file is set. |
| 121 | func (cs *Certstreamscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#) CreateIndexFilescip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#CreateIndexFile().(outFile string) error { |
| 122 | // If there is no watcher initialized, create a new one |
| 123 | if cs.watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher. == nil { |
| 124 | cs.watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher. = &certificatetransparencyscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/.Watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/Watcher#{} |
| 125 | } |
| 126 | |
| 127 | return cs.watcherscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/Certstream#watcher..CreateIndexFilescip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certificatetransparency`/Watcher#CreateIndexFile().(outFile) |
| 128 | } |
| 129 | |
| 130 | // signalHandler listens for signals in order to gracefully shut down the server. |
| 131 | // Executes the callback function when a signal is received. |
| 132 | func signalHandlerscip-go gomod github.com/d-Rickyy-b/certstream-server-go . `github.com/d-Rickyy-b/certstream-server-go/internal/certstream`/signalHandler().(signals chan osscip-go gomod github.com/golang/go/src go1.25.0 os/.Signalscip-go gomod github.com/golang/go/src go1.25.0 os/Signal#, callback func()) { |
| 133 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printlnscip-go gomod github.com/golang/go/src go1.25.0 log/Println().("Listening for signals...") |
| 134 | sig := <-signals |
| 135 | logscip-go gomod github.com/golang/go/src go1.25.0 log/.Printfscip-go gomod github.com/golang/go/src go1.25.0 log/Printf().("Received signal %v. Shutting down...\n", sig) |
| 136 | callback() |
| 137 | osscip-go gomod github.com/golang/go/src go1.25.0 os/.Exitscip-go gomod github.com/golang/go/src go1.25.0 os/Exit().(0) |
| 138 | } |