@@ -23,29 +23,29 @@ var browserIdentityKeywords = []string{
23
23
"mozilla" , "chrome" , "safari" , "firefox" , "edge" , "opera" , "msie" ,
24
24
}
25
25
26
- type SessionProxy struct {
26
+ type SandboxProxy struct {
27
27
sandboxes * smap.Map [string ]
28
28
server * http.Server
29
29
}
30
30
31
- func New (port uint ) * SessionProxy {
31
+ func New (port uint ) * SandboxProxy {
32
32
server := & http.Server {Addr : fmt .Sprintf (":%d" , port )}
33
33
34
- return & SessionProxy {
34
+ return & SandboxProxy {
35
35
server : server ,
36
36
sandboxes : smap .New [string ](),
37
37
}
38
38
}
39
39
40
- func (p * SessionProxy ) AddSandbox (sandboxID , ip string ) {
40
+ func (p * SandboxProxy ) AddSandbox (sandboxID , ip string ) {
41
41
p .sandboxes .Insert (sandboxID , ip )
42
42
}
43
43
44
- func (p * SessionProxy ) RemoveSandbox (sandboxID string ) {
44
+ func (p * SandboxProxy ) RemoveSandbox (sandboxID string ) {
45
45
p .sandboxes .Remove (sandboxID )
46
46
}
47
47
48
- func (p * SessionProxy ) Start () error {
48
+ func (p * SandboxProxy ) Start () error {
49
49
// similar values to our old the nginx configuration
50
50
serverTransport := & http.Transport {
51
51
Proxy : http .ProxyFromEnvironment ,
@@ -61,14 +61,14 @@ func (p *SessionProxy) Start() error {
61
61
return p .server .ListenAndServe ()
62
62
}
63
63
64
- func (p * SessionProxy ) Shutdown (ctx context.Context ) {
64
+ func (p * SandboxProxy ) Shutdown (ctx context.Context ) {
65
65
err := p .server .Shutdown (ctx )
66
66
if err != nil {
67
67
zap .L ().Error ("failed to shutdown proxy server" , zap .Error (err ))
68
68
}
69
69
}
70
70
71
- func (p * SessionProxy ) proxyHandler (transport * http.Transport ) func (w http.ResponseWriter , r * http.Request ) {
71
+ func (p * SandboxProxy ) proxyHandler (transport * http.Transport ) func (w http.ResponseWriter , r * http.Request ) {
72
72
activeConnections , err := meters .GetUpDownCounter (meters .ActiveConnectionsCounterMeterName )
73
73
if err != nil {
74
74
zap .L ().Error ("failed to create active connections counter" , zap .Error (err ))
@@ -146,7 +146,7 @@ func (p *SessionProxy) proxyHandler(transport *http.Transport) func(w http.Respo
146
146
}
147
147
}
148
148
149
- func (p * SessionProxy ) buildHtmlClosedPortError (sandboxId string , host string , port uint64 ) []byte {
149
+ func (p * SandboxProxy ) buildHtmlClosedPortError (sandboxId string , host string , port uint64 ) []byte {
150
150
replacements := map [string ]string {
151
151
"{{sandbox_id}}" : sandboxId ,
152
152
"{{sandbox_port}}" : strconv .FormatUint (port , 10 ),
@@ -161,7 +161,7 @@ func (p *SessionProxy) buildHtmlClosedPortError(sandboxId string, host string, p
161
161
return []byte (adjustedErrTemplate )
162
162
}
163
163
164
- func (p * SessionProxy ) buildJsonClosedPortError (sandboxId string , port uint64 ) []byte {
164
+ func (p * SandboxProxy ) buildJsonClosedPortError (sandboxId string , port uint64 ) []byte {
165
165
response := map [string ]interface {}{
166
166
"error" : "The sandbox is running but port is not open" ,
167
167
"sandbox_id" : sandboxId ,
@@ -172,7 +172,7 @@ func (p *SessionProxy) buildJsonClosedPortError(sandboxId string, port uint64) [
172
172
return responseBytes
173
173
}
174
174
175
- func (p * SessionProxy ) isBrowser (userAgent string ) bool {
175
+ func (p * SandboxProxy ) isBrowser (userAgent string ) bool {
176
176
userAgent = strings .ToLower (userAgent )
177
177
for _ , keyword := range browserIdentityKeywords {
178
178
if strings .Contains (userAgent , keyword ) {
0 commit comments