Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Add a --bind flag for local port #82

Merged
merged 18 commits into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor
bin
.vscode
sshcode
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func main() {
skipSyncFlag = flag.Bool("skipsync", false, "skip syncing local settings and extensions to remote host")
sshFlags = flag.String("ssh-flags", "", "custom SSH flags")
syncBack = flag.Bool("b", false, "sync extensions back on termination")
hostFlag = flag.String("host", "127.0.0.1", "custom host dns")
printVersion = flag.Bool("version", false, "print version information and exit")
)

Expand All @@ -53,9 +54,10 @@ func main() {
}

err := sshCode(host, dir, options{
skipSync: *skipSyncFlag,
sshFlags: *sshFlags,
syncBack: *syncBack,
skipSync: *skipSyncFlag,
sshFlags: *sshFlags,
localHost: *hostFlag,
syncBack: *syncBack,
})

if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions sshcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type options struct {
skipSync bool
syncBack bool
localPort string
localHost string
remotePort string
sshFlags string
}
Expand Down Expand Up @@ -99,8 +100,8 @@ func sshCode(host, dir string, o options) error {
if err != nil {
return xerrors.Errorf("failed to start code-server: %w", err)
}

url := "http://127.0.0.1:" + o.localPort
flog.Info("Using local host value: " + o.localHost)
url := "http://" + o.localHost + ":" + o.localPort
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()

Expand Down