Fix issue with replying with port

This commit is contained in:
PhatPhuckDave
2024-07-21 19:16:22 +02:00
parent b5f3f660f4
commit 97e107b973
2 changed files with 7 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
main.exe

View File

@@ -4,8 +4,9 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"os"
"net/http" "net/http"
"os"
"strings"
) )
var Error *log.Logger var Error *log.Logger
@@ -26,7 +27,10 @@ func init() {
func main() { func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, r.RemoteAddr) fullIP := r.RemoteAddr
parts := strings.Split(fullIP, ":")
ip := parts[0]
fmt.Fprintf(w, ip)
}) })
http.ListenAndServe(":8080", nil) http.ListenAndServe(":8080", nil)