Skip to content

Commit 36ed363

Browse files
committed
check if port is occupied
1 parent a10097b commit 36ed363

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@
4646

4747
## Product Web Site (产品网站)
4848

49-
English: https://janusec.github.io/
50-
中文: https://janusec.github.io/cn/
49+
English:
50+
https://janusec.github.io/
51+
https://doc.janusec.com/
52+
53+
中文:
54+
https://doc.janusec.com/cn/
55+
https://janusec.github.io/cn/
5156

5257
## Requirements (需求)
5358

build_arm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build janusec.go
1+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build janusec.go
22

janusec.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,21 @@ func main() {
133133
gateMux.HandleFunc("/", gateway.ReverseHandlerFunc)
134134
ctxGateMux := AddContextHandler(gateMux)
135135
go func() {
136-
listen, _ := net.Listen("tcp", ":80")
137-
utils.CheckError("Listen 80 Failed", http.Serve(listen, ctxGateMux))
136+
listen, err := net.Listen("tcp", ":80")
137+
if err != nil {
138+
utils.CheckError("Port 80 is occupied.", err)
139+
utils.DebugPrintln("Port 80 is occupied.", err)
140+
os.Exit(1)
141+
}
142+
http.Serve(listen, ctxGateMux)
138143
}()
139-
listen, _ := tls.Listen("tcp", ":443", tlsconfig)
140-
utils.CheckError("Listen 443 Failed", http.Serve(listen, ctxGateMux))
144+
listen, err := tls.Listen("tcp", ":443", tlsconfig)
145+
if err != nil {
146+
utils.CheckError("Port 443 is occupied.", err)
147+
utils.DebugPrintln("Port 443 is occupied.", err)
148+
os.Exit(1)
149+
}
150+
http.Serve(listen, ctxGateMux)
141151
}
142152

143153
// AddContextHandler to add context handler

0 commit comments

Comments
 (0)