fix: macOS bcopy conflict and Docker host binding
- Fix #11: Guard bcopy/bzero declarations with _VISUALCPP in commoninclude.h to avoid redefinition errors on macOS where <strings.h> provides them - Fix #12: Add --host flag to serve command, default 127.0.0.1 Docker now binds to 0.0.0.0 so Colima can reach the server from host - Also fix truncate() panic when n < 3
This commit is contained in:
+1
-1
@@ -34,4 +34,4 @@ COPY scripts/extract_wavs.sh /usr/local/bin/
|
|||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
ENTRYPOINT ["fetch"]
|
ENTRYPOINT ["fetch"]
|
||||||
CMD ["serve", "-p", "8080"]
|
CMD ["serve", "-p", "8080", "--host", "0.0.0.0"]
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ Pipeline flags:
|
|||||||
|
|
||||||
Serve flags:
|
Serve flags:
|
||||||
-p, --port 0 HTTP port (0 = auto-assign)
|
-p, --port 0 HTTP port (0 = auto-assign)
|
||||||
|
--host 127.0.0.1 HTTP bind address (use 0.0.0.0 for Docker)
|
||||||
--no-browser don't open browser automatically`)
|
--no-browser don't open browser automatically`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,6 +597,9 @@ func truncate(s string, n int) string {
|
|||||||
if len(s) <= n {
|
if len(s) <= n {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
if n < 3 {
|
||||||
|
return s[:n]
|
||||||
|
}
|
||||||
return s[:n-3] + "..."
|
return s[:n-3] + "..."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ var webUI embed.FS
|
|||||||
|
|
||||||
func cmdServe(args []string) {
|
func cmdServe(args []string) {
|
||||||
port := 0
|
port := 0
|
||||||
|
host := "127.0.0.1"
|
||||||
openBrowser := true
|
openBrowser := true
|
||||||
|
|
||||||
for i := 0; i < len(args); i++ {
|
for i := 0; i < len(args); i++ {
|
||||||
@@ -33,6 +34,11 @@ func cmdServe(args []string) {
|
|||||||
port, _ = strconv.Atoi(args[i+1])
|
port, _ = strconv.Atoi(args[i+1])
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
case "--host":
|
||||||
|
if i+1 < len(args) {
|
||||||
|
host = args[i+1]
|
||||||
|
i++
|
||||||
|
}
|
||||||
case "--no-browser":
|
case "--no-browser":
|
||||||
openBrowser = false
|
openBrowser = false
|
||||||
}
|
}
|
||||||
@@ -52,18 +58,19 @@ func cmdServe(args []string) {
|
|||||||
mux.HandleFunc("/api/extract", handleAPIExtract)
|
mux.HandleFunc("/api/extract", handleAPIExtract)
|
||||||
mux.HandleFunc("/api/progress", handleProgress)
|
mux.HandleFunc("/api/progress", handleProgress)
|
||||||
|
|
||||||
addr := fmt.Sprintf("127.0.0.1:%d", port)
|
addr := fmt.Sprintf("%s:%d", host, port)
|
||||||
listener, err := net.Listen("tcp", addr)
|
listener, err := net.Listen("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal("listen: %v", err)
|
fatal("listen: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
realPort := listener.Addr().(*net.TCPAddr).Port
|
realPort := listener.Addr().(*net.TCPAddr).Port
|
||||||
|
realHost := listener.Addr().(*net.TCPAddr).IP.String()
|
||||||
|
|
||||||
fmt.Printf("\n AKAI Utils Server\n")
|
fmt.Printf("\n AKAI Utils Server\n")
|
||||||
fmt.Printf(" =================\n\n")
|
fmt.Printf(" =================\n\n")
|
||||||
fmt.Printf(" Local: http://localhost:%d\n", realPort)
|
fmt.Printf(" Local: http://%s:%d\n", realHost, realPort)
|
||||||
fmt.Printf(" API: http://localhost:%d/api/\n", realPort)
|
fmt.Printf(" API: http://%s:%d/api/\n", realHost, realPort)
|
||||||
fmt.Printf(" Quit: Ctrl+C\n\n")
|
fmt.Printf(" Quit: Ctrl+C\n\n")
|
||||||
|
|
||||||
if openBrowser {
|
if openBrowser {
|
||||||
|
|||||||
Vendored
+2
@@ -185,8 +185,10 @@ extern int optopt;
|
|||||||
#define LSEEK64 lseek64
|
#define LSEEK64 lseek64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _VISUALCPP
|
||||||
extern void bcopy(const void *src,void *dst,size_t len);
|
extern void bcopy(const void *src,void *dst,size_t len);
|
||||||
extern void bzero(void *b,size_t len);
|
extern void bzero(void *b,size_t len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user