Skip to content

Commit 24a1228

Browse files
Add latency1 paths to access controller (#22)
* Add latency1 paths to txcontroller. * Update names and comment
1 parent 1daff59 commit 24a1228

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

cmd/msak-server/server.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,21 @@ func main() {
8484
if (tokenVerify) && err != nil {
8585
rtx.Must(err, "Failed to load verifier")
8686
}
87-
// Enforce tokens on uploads and downloads.
88-
throughput1TxPaths := controller.Paths{
89-
spec.DownloadPath: true,
90-
spec.UploadPath: true,
87+
// Enforce tokens and txcontroller on every endpoint.
88+
txControllerPaths := controller.Paths{
89+
spec.DownloadPath: true,
90+
spec.UploadPath: true,
91+
latency1spec.AuthorizeV1: true,
92+
latency1spec.ResultV1: true,
9193
}
92-
throughput1TokenPaths := controller.Paths{
93-
spec.DownloadPath: true,
94-
spec.UploadPath: true,
94+
tokenPaths := controller.Paths{
95+
spec.DownloadPath: true,
96+
spec.UploadPath: true,
97+
latency1spec.AuthorizeV1: true,
98+
latency1spec.ResultV1: true,
9599
}
96100
acm, _ := controller.Setup(ctx, v, tokenVerify, tokenMachine,
97-
throughput1TxPaths, throughput1TokenPaths)
101+
txControllerPaths, tokenPaths)
98102

99103
mux := http.NewServeMux()
100104
latency1Handler := latency1.NewHandler(*flagDataDir, *flagLatencyTTL)
@@ -106,39 +110,39 @@ func main() {
106110
latency1Handler.Authorize))
107111
mux.Handle(latency1spec.ResultV1, http.HandlerFunc(
108112
latency1Handler.Result))
109-
throughput1ServerCleartext := httpServer(
113+
serverCleartext := httpServer(
110114
*flagEndpointCleartext,
111115
acm.Then(mux))
112116

113117
log.Info("About to listen for ws tests", "endpoint", *flagEndpointCleartext)
114118

115-
tcpl, err := net.Listen("tcp", throughput1ServerCleartext.Addr)
119+
tcpl, err := net.Listen("tcp", serverCleartext.Addr)
116120
rtx.Must(err, "failed to create listener")
117121
l := netx.NewListener(tcpl.(*net.TCPListener))
118122
defer l.Close()
119123

120124
go func() {
121-
err := throughput1ServerCleartext.Serve(l)
125+
err := serverCleartext.Serve(l)
122126
rtx.Must(err, "Could not start cleartext server")
123-
defer throughput1ServerCleartext.Close()
127+
defer serverCleartext.Close()
124128
}()
125129

126130
// Only start TLS-based services if certs and keys are provided
127131
if *flagCertFile != "" && *flagKeyFile != "" {
128-
throughput1Server := httpServer(
132+
server := httpServer(
129133
*flagEndpoint,
130134
acm.Then(mux))
131135
log.Info("About to listen for wss tests", "endpoint", *flagEndpoint)
132136

133-
tcpl, err := net.Listen("tcp", throughput1Server.Addr)
137+
tcpl, err := net.Listen("tcp", server.Addr)
134138
rtx.Must(err, "failed to create listener")
135139
l := netx.NewListener(tcpl.(*net.TCPListener))
136140
defer l.Close()
137141

138142
go func() {
139-
err := throughput1Server.ServeTLS(l, *flagCertFile, *flagKeyFile)
143+
err := server.ServeTLS(l, *flagCertFile, *flagKeyFile)
140144
rtx.Must(err, "Could not start cleartext server")
141-
defer throughput1Server.Close()
145+
defer server.Close()
142146
}()
143147
}
144148

0 commit comments

Comments
 (0)