Skip to content

Commit

Permalink
add webhook addr
Browse files Browse the repository at this point in the history
  • Loading branch information
muckelba committed Oct 11, 2024
1 parent 7a4c2c1 commit ec00ffd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
four2six:
image: ghcr.io/muckelba/four2six:latest
image: ghcr.io/muckelba/four2six:main
restart: unless-stopped
networks:
- default
Expand Down
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Config struct {
DataDir string
WebhookToken string
WebhookListenPort string
WebhookListenAddr string
TunnelListenAddr string
mu sync.RWMutex
}
Expand Down Expand Up @@ -149,7 +150,8 @@ func main() {

sourceListenAddr := parseConfigEnv("SRC_LISTEN_ADDR", "0.0.0.0")

webhookListener := parseConfigEnv("WEBHOOK_LISTEN_PORT", "8081")
webhookPort := parseConfigEnv("WEBHOOK_LISTEN_PORT", "8081")
webhookAddr := parseConfigEnv("WEBHOOK_LISTEN_ADDR", "0.0.0.0")

dataPath := "data" // Name of the data directory

Expand All @@ -161,7 +163,8 @@ func main() {
WebhookToken: token,
DataDir: filepath.Join(".", dataPath),
FilePath: filepath.Join(dataPath, "ipv6_address.txt"),
WebhookListenPort: webhookListener,
WebhookListenPort: webhookPort,
WebhookListenAddr: webhookAddr,
TunnelListenAddr: sourceListenAddr,
}

Expand All @@ -173,8 +176,9 @@ func main() {
// Start the HTTP server to listen for webhook updates.
http.HandleFunc("/update", updateIPv6Address(config))
go func() {
log.Printf("Starting webhook server on %s\n", config.WebhookListenPort)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", config.WebhookListenPort), nil))
fullAddr := fmt.Sprintf("%s:%s", config.WebhookListenAddr, config.WebhookListenPort)
log.Printf("Starting webhook server on %s\n", fullAddr)
log.Fatal(http.ListenAndServe(fullAddr, nil))
}()

for i, port := range config.IPv4Ports {
Expand Down

0 comments on commit ec00ffd

Please sign in to comment.