Skip to content

Commit 98a6564

Browse files
committed
Let customize the port
1 parent 8467dbe commit 98a6564

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.env.sample

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ RELAY_URL="wss://chronicle.xxxxxxxx.com"
88
RELAY_ICON="https://chronicle.xxxxxxxx.com/web/icon.png"
99
RELAY_CONTACT="your_email_or_website"
1010

11+
# The port where the relay is esposed
12+
RELAY_PORT="3334"
13+
1114
# The relay pubkey, in hex format
1215
RELAY_PUBKEY="YourPublicKey"
1316

main.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Config struct {
3131
RelayDescription string
3232
DBPath string
3333
RelayURL string
34+
RelayPort string
3435
WebPath string
3536
RefreshInterval int
3637
MinFollowers int
@@ -161,12 +162,14 @@ func main() {
161162
RelayPubkey string
162163
RelayDescription string
163164
RelayURL string
165+
RelayPort string
164166
RelayOwner string
165167
}{
166168
RelayName: config.RelayName,
167169
RelayPubkey: config.RelayPubkey,
168170
RelayDescription: config.RelayDescription,
169171
RelayURL: config.RelayURL,
172+
RelayPort: config.RelayPort,
170173
RelayOwner: config.OwnerPubkey,
171174
}
172175
err := tmpl.Execute(w, data)
@@ -175,8 +178,8 @@ func main() {
175178
}
176179
})
177180

178-
log.Println("🎉 Relay running on port :3334")
179-
err := http.ListenAndServe(":3334", relay)
181+
log.Println("🎉 Relay running on port", config.RelayPort)
182+
err := http.ListenAndServe(":"+config.RelayPort, relay)
180183
if err != nil {
181184
log.Fatal(err)
182185
}
@@ -211,6 +214,7 @@ func LoadConfig() Config {
211214
RelayIcon: getEnv("RELAY_ICON"),
212215
DBPath: getEnv("DB_PATH"),
213216
RelayURL: getEnv("RELAY_URL"),
217+
RelayPort: getEnv("RELAY_PORT"),
214218
WebPath: getEnv("WEB_PATH"),
215219
RefreshInterval: refreshInterval,
216220
MinFollowers: minFollowers,

0 commit comments

Comments
 (0)