-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
executable file
·46 lines (37 loc) · 1.03 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"flag"
"fmt"
"os"
"strings"
"yaman/timeout/http"
"yaman/timeout/tcp"
)
func main() {
portParameter := flag.String("port", "8080", "port number to run http from")
protoParameter := flag.String("proto", "http", "protocol to run timeouts")
flag.Parse()
port := os.Getenv("PORT")
if len(port) == 0 && len(*portParameter) > 0 {
port = *portParameter
}
proto := os.Getenv("PROTO")
if len(proto) == 0 && len(*protoParameter) > 0 {
proto = *protoParameter
}
switch {
case strings.Contains(proto, "http"):
fmt.Println("Running Go HTTP Timeout...")
go http.StartRouter(port)
case strings.Contains(proto, "tcp"):
fmt.Println("Running Go TCP Timeout...")
go tcp.ListenAndDoNotAnswer()
go tcp.ListenAndAnswerWithEmptyString()
go tcp.ListenAndAnswerWithEmptyStringAfterClientSendsData()
go tcp.ListenAndAnswerWithMalformedStringImmediately()
go tcp.ListenAndAnswerWithMalformedStringAfterClientSendsData()
go tcp.ListenAndAnswerEvery5Seconds()
go tcp.ListenAndAnswerEvery30Seconds()
}
select {}
}