Skip to content

Commit bbfa05b

Browse files
committed
golt: add GOLT_BIND_PORT option
1 parent 458a41a commit bbfa05b

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
# Why?
66

77
[The official recommendation](https://help.jagex.com/hc/en-gb/articles/13413514881937-Downloading-the-Jagex-Launcher-on-Linux)
8-
points to several community projects, most of which involve running the launcher in Wine or a similar environment. However, I really wanted a native solution, or one
8+
points to several community projects, most of which involve running the launcher in Wine or a similar environment.
9+
However, I really wanted a native solution, or one
910
that didn't require installing a 1.5GB compatibility layer solely for launcher functionality.
1011

11-
While there is a project that served as the inspiration for this one, and functions seamlessly on Linux, there were some boxes that it didn't tick for me:
12+
While there is a project that served as the inspiration for this one, and functions seamlessly on Linux, there were some
13+
boxes that it didn't tick for me:
1214

1315
- Its installation size is ~460MB
1416
- Lack of support for overriding the client launch command/environment
@@ -18,7 +20,8 @@ In comparison, the linux-amd64 build for `golt` is a single 6.8MB binary.
1820

1921
# Installation
2022

21-
Either download the latest binary from the [Releases](https://github.com/chowder/golt/releases) page (or build it yourself), and add it to a directory on your `PATH`.
23+
Either download the latest binary from the [Releases](https://github.com/chowder/golt/releases) page (or build it
24+
yourself), and add it to a directory on your `PATH`.
2225

2326
Then, create a desktop entry for the application:
2427

@@ -52,17 +55,18 @@ The login flow is currently done in the browser:
5255
- The OAuth login redirects to a page which invokes a scheme handler
5356
- The game login step redirects to `http://localhost`
5457

55-
These redirect URLs are validated server side, so cannot be modified on the client side.
58+
These redirect URLs are validated server side, so cannot be modified on the client side.
5659

57-
As for the iptable entry, most Linux distros don't allow binding to port 80, so `golt` binds to port 8080 instead.
60+
As for the iptable entry, most Linux distros don't allow binding to port 80, so `golt` binds to port 8080 instead.
5861

5962
</details>
6063

6164
# Configuration
6265

63-
| Environment Variable | Default | Description |
64-
|----------------------|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
65-
| `GOLT_GAME_PATH` | `RuneLite.AppImage` | Either a binary on `PATH`, or an absolute path to the client to launch.<br/>This value is passed to `exec.Command`([docs](https://pkg.go.dev/os/exec#Command)) |
66+
| Environment Variable | Default | Description |
67+
|----------------------|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
68+
| `GOLT_GAME_PATH` | `RuneLite.AppImage` | Either a binary on `PATH`, or an absolute path to the client to launch.<br/>This value is passed to `exec.Command`([docs](https://pkg.go.dev/os/exec#Command)) |
69+
| `GOLT_BIND_PORT` | `8080` | Local port to which `golt` will bind to to receive the OAuth response callback.<br/>If this is not `80`, you must set up an iptable entry to redirect inbound traffic from port `80` to this port. |
6670

6771
# Disclaimer
6872

internal/golt/requests.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import (
1111
"github.com/pkg/browser"
1212
"golang.org/x/oauth2"
1313
"log"
14+
"os"
1415
"net/http"
16+
"strconv"
1517
"strings"
1618
)
1719

@@ -179,10 +181,22 @@ func StandardLogin(idToken string) (*Tuple[string, string], error) {
179181
channel <- Tuple[string, string]{code, idToken}
180182
})
181183

184+
port := 8080
185+
186+
if val, exists := os.LookupEnv("GOLT_BIND_PORT"); exists {
187+
var err error
188+
port, err = strconv.Atoi(val)
189+
if err != nil {
190+
Die(errors.New("could not parse GOLT_BIND_PORT as integer"))
191+
}
192+
}
193+
194+
log.Println("Binding to port:", port)
195+
182196
// Start the server
183197
server := &http.Server{
184198
// TODO: sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080
185-
Addr: ":8080",
199+
Addr: ":" + strconv.Itoa(port),
186200
Handler: nil,
187201
}
188202
go func() {

0 commit comments

Comments
 (0)