@@ -27,6 +27,7 @@ import (
2727 "io"
2828 "log"
2929 mrand "math/rand/v2"
30+ "net"
3031 "net/http"
3132 "os"
3233 "strconv"
@@ -149,7 +150,7 @@ func init() {
149150 flag .IntVar (& frequency , "frequency" , 10 , "How often to run probers (in seconds)" )
150151 flag .StringVar (& logStyle , "logStyle" , "prod" , "Log style to use (dev or prod)" )
151152 flag .StringVar (& addr , "addr" , ":8080" , "Port to expose prometheus to" )
152- flag .IntVar (& grpcPort , "grpc-port" , 5554 , "Port for Fulcio gRPC endpoint (only if configured) " )
153+ flag .IntVar (& grpcPort , "grpc-port" , 0 , "Port for Fulcio gRPC endpoint" )
153154
154155 flag .UintVar (& retries , "retry" , 4 , "Maximum number of retries before marking HTTP request as failed" )
155156 flag .BoolVar (& oneTime , "one-time" , false , "Whether to run only one time and exit" )
@@ -274,8 +275,12 @@ func main() {
274275 } else if strings .HasPrefix (fulcioGrpcURL , "http://" ) {
275276 fulcioGrpcURL = strings .TrimPrefix (fulcioGrpcURL , "http://" )
276277 }
277- if idx := strings .LastIndex (fulcioGrpcURL , ":" ); idx != - 1 {
278- fulcioGrpcURL = fulcioGrpcURL [:idx + 1 ] + strconv .Itoa (grpcPort )
278+ if grpcPort != 0 {
279+ host , _ , err := net .SplitHostPort (fulcioGrpcURL )
280+ if err != nil {
281+ host = fulcioGrpcURL
282+ }
283+ fulcioGrpcURL = net .JoinHostPort (host , strconv .Itoa (grpcPort ))
279284 }
280285
281286 tsaServices , err := root .SelectServices (signingConfig .TimestampAuthorityURLs (), root.ServiceConfiguration {Selector : prototrustroot .ServiceSelector_ALL }, sign .TimestampAuthorityAPIVersions , time .Now ())
0 commit comments