-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.go
54 lines (45 loc) · 981 Bytes
/
run.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
47
48
49
50
51
52
53
54
package main
import (
"crypto/tls"
"fmt"
"net"
"net/url"
"os"
"github.com/lucas-clemente/quic-go"
)
func run(network, local, addr, rawurl, filename string,
tlsCfg *tls.Config, cfg *quic.Config,
buffer []byte, dst *os.File,
u *url.URL, rtmpType bool,
quit chan os.Signal) {
defer func() {
close(quit)
}()
if addr == "" {
ips, err := net.LookupIP(u.Host)
if err != nil || len(ips) == 0 {
fmt.Println(err)
return
}
printDNS(u.Host, ips)
switch u.Scheme {
case "http":
addr = ips[0].String() + ":80"
case "https":
addr = ips[0].String() + ":443"
case "rtmp":
addr = ips[0].String() + ":1935"
default:
}
}
switch u.Scheme {
case "http":
h1OverQUIC(network, local, addr, rawurl, tlsCfg, cfg, buffer, dst)
case "https":
h2OverQUIC(network, local, addr, rawurl, tlsCfg, cfg, buffer, dst)
case "rtmp":
rtmpOverQUIC(network, local, addr, rawurl, tlsCfg, cfg, filename, rtmpType)
default:
fmt.Println("unsupport")
}
}