Skip to content

Commit

Permalink
Removing WEBEXEC_SERVER_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
daonb committed Jul 2, 2024
1 parent 248febd commit 5e79b7d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ $ go install ./...

webexec has a signlaing server that listen for connection request on
ports 7777. By default it listens only for localhost. To
open webexec to the world set `WEBEXEC_SERVER_URL` to the the server's
public URL, default is `http://localhost:7777`.
open webexec to the world set the http_server under [net] in the config file
to 0.0.0.0:7777.

Once communication is established, WebRTC uses UDP ports with
a default range of 60000-61000.
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ run.

### net

- http_server: The address the https server listen on. default: `0.0.0.0:7777`
- http_server: The address the https server listen on. default: `127.0.0.1:7777`
set to 0.0.0.0:7777 to listen on all interfaces
- udp_port_min: the minimum UDP port to use
- udp_port_max: the maximum UDP port to use

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/dchest/uniuri v1.2.0
github.com/fatih/color v1.17.0
github.com/google/uuid v1.3.1
github.com/gorilla/websocket v1.4.2
github.com/gorilla/websocket v1.5.1
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/pelletier/go-toml v1.9.3
github.com/pion/webrtc/v3 v3.2.32
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
Expand Down
15 changes: 5 additions & 10 deletions httpserver/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io"
"io/ioutil"
"net/http"
"os"
"time"

"github.com/google/uuid"
Expand All @@ -30,7 +29,6 @@ type ConnectHandler struct {
authBackend AuthBackend
peerConf *peers.Conf
logger *zap.SugaredLogger
address AddressType
sessions map[uuid.UUID]*peers.Peer
}

Expand All @@ -44,17 +42,10 @@ type ConnectRequest struct {
func NewConnectHandler(
backend AuthBackend, conf *peers.Conf, logger *zap.SugaredLogger) *ConnectHandler {

adress := os.Getenv("WEBEXEC_SERVER_URL")
if adress == "" {
adress = "http://localhost:7777"
}
logger.Infof("Using %s as server address", adress)

return &ConnectHandler{
authBackend: backend,
peerConf: conf,
logger: logger,
address: AddressType(adress),
sessions: make(map[uuid.UUID]*peers.Peer),
}
}
Expand Down Expand Up @@ -167,7 +158,11 @@ func (h *ConnectHandler) HandleOffer(w http.ResponseWriter, r *http.Request) {

w.Header().Set("Content-Type", "application/sdp")
w.Header().Set("ETag", fmt.Sprintf("%x", time.Now().Unix()))
url := fmt.Sprintf("%s/candidates/%s", h.address, sessionID)
scheme := r.Header.Get("X-Forwarded-Proto")
if scheme == "" {
scheme = "http" // Assume http if header is missing.
}
url := fmt.Sprintf("%s://%s/candidates/%s", scheme, r.Host, sessionID)
w.Header().Set("Location", url)
w.WriteHeader(http.StatusCreated)
w.Write([]byte(answer.SDP))
Expand Down
1 change: 0 additions & 1 deletion httpserver/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ func FuncTestOffer(t *testing.T) {
authBackend: a,
peerConf: conf,
logger: logger,
address: AddressType("127.0.0.1:7777"),
}
h.HandleOffer(w, req)
require.Equal(t, http.StatusCreated, w.Code)
Expand Down

0 comments on commit 5e79b7d

Please sign in to comment.