@@ -22,7 +22,6 @@ import (
2222 "os"
2323 "os/signal"
2424 "slices"
25- "strings"
2625 "syscall"
2726 "time"
2827
@@ -45,7 +44,6 @@ var sshAgentFlag = flag.String("ssh-agent", "litewitness.sock", "path to ssh-age
4544var listenFlag = flag .String ("listen" , "localhost:7380" , "address to listen for HTTP requests" )
4645var noListenFlag = flag .Bool ("no-listen" , false , "do not open any listening socket, rely exclusively on bastions" )
4746var keyFlag = flag .String ("key" , "" , "SSH fingerprint (with SHA256: prefix) of the witness key" )
48- var bastionFlag = flag .String ("bastion" , "" , "address of the bastion(s) to reverse proxy through, comma separated, the first online one is selected" )
4947var testCertFlag = flag .Bool ("testcert" , false , "use rootCA.pem for connections to the bastion" )
5048var obscurityFlag = flag .Bool ("obscurity" , false , "enable obscurity mode (disable / and /logz endpoints)" )
5149var listenMetricsFlag = flag .String ("listen-metrics" , "" , "address to listen for metrics requests, instead of exposing them on the main listener" )
@@ -204,7 +202,7 @@ func main() {
204202 retry := 0
205203 for {
206204 startTime := time .Now ()
207- err := connectToBastion (ctx , addr , bastionCert , srv , true )
205+ err := connectToBastion (ctx , addr , bastionCert , srv )
208206 duration := time .Since (startTime )
209207 slog .Warn ("bastion connection failed" , "bastion" , addr , "duration" , duration , "err" , err )
210208
@@ -256,20 +254,7 @@ func main() {
256254 bastionSet .Configure (ctx , logBastions )
257255 })
258256
259- if * bastionFlag != "" {
260- go func () {
261- for _ , bastion := range strings .Split (* bastionFlag , "," ) {
262- err := connectToBastion (ctx , bastion , bastionCert , srv , false )
263- if err == errBastionDisconnected {
264- // Connection succeeded and then was interrupted. Restart to
265- // let the scheduler apply any backoff, and then retry all bastions.
266- e <- err
267- return
268- }
269- }
270- e <- errors .New ("couldn't connect to any bastion" )
271- }()
272- } else if ! * noListenFlag {
257+ if ! * noListenFlag {
273258 go func () {
274259 slog .Info ("listening" , "addr" , * listenFlag )
275260 e <- srv .ListenAndServe ()
@@ -418,7 +403,7 @@ func indexHandler(w *witness.Witness) http.HandlerFunc {
418403
419404var errBastionDisconnected = errors .New ("connection to bastion interrupted" )
420405
421- func connectToBastion (ctx context.Context , bastion string , cert tls.Certificate , srv * http.Server , logSpecific bool ) error {
406+ func connectToBastion (ctx context.Context , bastion string , cert tls.Certificate , srv * http.Server ) error {
422407 slog .Info ("connecting to bastion" , "bastion" , bastion )
423408 dialCtx , cancel := context .WithTimeout (ctx , 5 * time .Second )
424409 defer cancel ()
@@ -454,9 +439,7 @@ func connectToBastion(ctx context.Context, bastion string, cert tls.Certificate,
454439 }(ctx )
455440
456441 slog .Info ("connected to bastion" , "bastion" , bastion )
457- if logSpecific {
458- ctx = witness .ContextWithBastion (ctx , bastion )
459- }
442+ ctx = witness .ContextWithBastion (ctx , bastion )
460443 // TODO: find a way to surface the fatal error, especially since with
461444 // TLS 1.3 it might be that the bastion rejected the client certificate.
462445 (& http2.Server {
0 commit comments