@@ -23,29 +23,29 @@ var browserIdentityKeywords = []string{
2323 "mozilla" , "chrome" , "safari" , "firefox" , "edge" , "opera" , "msie" ,
2424}
2525
26- type SessionProxy struct {
26+ type SandboxProxy struct {
2727 sandboxes * smap.Map [string ]
2828 server * http.Server
2929}
3030
31- func New (port uint ) * SessionProxy {
31+ func New (port uint ) * SandboxProxy {
3232 server := & http.Server {Addr : fmt .Sprintf (":%d" , port )}
3333
34- return & SessionProxy {
34+ return & SandboxProxy {
3535 server : server ,
3636 sandboxes : smap .New [string ](),
3737 }
3838}
3939
40- func (p * SessionProxy ) AddSandbox (sandboxID , ip string ) {
40+ func (p * SandboxProxy ) AddSandbox (sandboxID , ip string ) {
4141 p .sandboxes .Insert (sandboxID , ip )
4242}
4343
44- func (p * SessionProxy ) RemoveSandbox (sandboxID string ) {
44+ func (p * SandboxProxy ) RemoveSandbox (sandboxID string ) {
4545 p .sandboxes .Remove (sandboxID )
4646}
4747
48- func (p * SessionProxy ) Start () error {
48+ func (p * SandboxProxy ) Start () error {
4949 // similar values to our old the nginx configuration
5050 serverTransport := & http.Transport {
5151 Proxy : http .ProxyFromEnvironment ,
@@ -61,14 +61,14 @@ func (p *SessionProxy) Start() error {
6161 return p .server .ListenAndServe ()
6262}
6363
64- func (p * SessionProxy ) Shutdown (ctx context.Context ) {
64+ func (p * SandboxProxy ) Shutdown (ctx context.Context ) {
6565 err := p .server .Shutdown (ctx )
6666 if err != nil {
6767 zap .L ().Error ("failed to shutdown proxy server" , zap .Error (err ))
6868 }
6969}
7070
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 ) {
7272 activeConnections , err := meters .GetUpDownCounter (meters .ActiveConnectionsCounterMeterName )
7373 if err != nil {
7474 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
146146 }
147147}
148148
149- func (p * SessionProxy ) buildHtmlClosedPortError (sandboxId string , host string , port uint64 ) []byte {
149+ func (p * SandboxProxy ) buildHtmlClosedPortError (sandboxId string , host string , port uint64 ) []byte {
150150 replacements := map [string ]string {
151151 "{{sandbox_id}}" : sandboxId ,
152152 "{{sandbox_port}}" : strconv .FormatUint (port , 10 ),
@@ -161,7 +161,7 @@ func (p *SessionProxy) buildHtmlClosedPortError(sandboxId string, host string, p
161161 return []byte (adjustedErrTemplate )
162162}
163163
164- func (p * SessionProxy ) buildJsonClosedPortError (sandboxId string , port uint64 ) []byte {
164+ func (p * SandboxProxy ) buildJsonClosedPortError (sandboxId string , port uint64 ) []byte {
165165 response := map [string ]interface {}{
166166 "error" : "The sandbox is running but port is not open" ,
167167 "sandbox_id" : sandboxId ,
@@ -172,7 +172,7 @@ func (p *SessionProxy) buildJsonClosedPortError(sandboxId string, port uint64) [
172172 return responseBytes
173173}
174174
175- func (p * SessionProxy ) isBrowser (userAgent string ) bool {
175+ func (p * SandboxProxy ) isBrowser (userAgent string ) bool {
176176 userAgent = strings .ToLower (userAgent )
177177 for _ , keyword := range browserIdentityKeywords {
178178 if strings .Contains (userAgent , keyword ) {
0 commit comments