mirror of
https://github.com/TecharoHQ/anubis.git
synced 2025-08-03 09:48:08 -04:00
fix(logs): Correctly format listener address (#162)
* fix: Correctly format listener address (https://github.com/TecharoHQ/anubis/issues/93) Handle addresses that include a hostname, not just ports. If the address starts with a colon, assume it's just a port and prefix it with "http://localhost". Otherwise, prefix the entire address with "http://". This ensures that the listener URL is correctly formatted regardless of whether it includes a hostname or just a port. Signed-off-by: Jason Cameron <git@jasoncameron.dev> * chore(docs): add changelog entry Signed-off-by: Jason Cameron <git@jasoncameron.dev> --------- Signed-off-by: Jason Cameron <git@jasoncameron.dev>
This commit is contained in:
parent
4bc00e5a65
commit
5a07684f99
@ -17,6 +17,7 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@ -82,7 +83,11 @@ func setupListener(network string, address string) (net.Listener, string) {
|
|||||||
case "unix":
|
case "unix":
|
||||||
formattedAddress = "unix:" + address
|
formattedAddress = "unix:" + address
|
||||||
case "tcp":
|
case "tcp":
|
||||||
formattedAddress = "http://localhost" + address
|
if strings.HasPrefix(address, ":") { // assume it's just a port e.g. :4259
|
||||||
|
formattedAddress = "http://localhost" + address
|
||||||
|
} else {
|
||||||
|
formattedAddress = "http://" + address
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
formattedAddress = fmt.Sprintf(`(%s) %s`, network, address)
|
formattedAddress = fmt.Sprintf(`(%s) %s`, network, address)
|
||||||
}
|
}
|
||||||
@ -245,10 +250,10 @@ func main() {
|
|||||||
h = internal.XForwardedForToXRealIP(h)
|
h = internal.XForwardedForToXRealIP(h)
|
||||||
|
|
||||||
srv := http.Server{Handler: h}
|
srv := http.Server{Handler: h}
|
||||||
listener, url := setupListener(*bindNetwork, *bind)
|
listener, listenerUrl := setupListener(*bindNetwork, *bind)
|
||||||
slog.Info(
|
slog.Info(
|
||||||
"listening",
|
"listening",
|
||||||
"url", url,
|
"url", listenerUrl,
|
||||||
"difficulty", *challengeDifficulty,
|
"difficulty", *challengeDifficulty,
|
||||||
"serveRobotsTXT", *robotsTxt,
|
"serveRobotsTXT", *robotsTxt,
|
||||||
"target", *target,
|
"target", *target,
|
||||||
|
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Verification page now shows hash rate and a progress bar for completion probability.
|
- Verification page now shows hash rate and a progress bar for completion probability.
|
||||||
- Added the `--debug-benchmark-js` flag for testing proof-of-work performance during development.
|
- Added the `--debug-benchmark-js` flag for testing proof-of-work performance during development.
|
||||||
- Use `TrimSuffix` instead of `TrimRight` on containerbuild
|
- Use `TrimSuffix` instead of `TrimRight` on containerbuild
|
||||||
|
- Fix the startup logs to correctly show the address and port the server is listening on
|
||||||
- Add [LibreJS](https://www.gnu.org/software/librejs/) banner to Anubis JavaScript to allow LibreJS users to run the challenge
|
- Add [LibreJS](https://www.gnu.org/software/librejs/) banner to Anubis JavaScript to allow LibreJS users to run the challenge
|
||||||
|
|
||||||
## v1.15.0
|
## v1.15.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user