mirror of
https://github.com/cunnie/sslip.io.git
synced 2025-10-05 23:56:50 +08:00
Placate the linter
- check for errors when I was previously skipping them - use module `time` better Drive-by: Shorter way to copy the new `index.html` to the 5 servers.
This commit is contained in:
@@ -124,8 +124,9 @@ Update the webservers with the HTML with new versions:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
ssh nono.io curl -L -o /www/sslip.io/document_root/index.html https://raw.githubusercontent.com/cunnie/sslip.io/main/k8s/document_root_sslip.io/index.html
|
ssh nono.io curl -L -o /www/sslip.io/document_root/index.html https://raw.githubusercontent.com/cunnie/sslip.io/main/k8s/document_root_sslip.io/index.html
|
||||||
ssh ns-aws.sslip.io curl -L -o /var/nginx/sslip.io/index.html https://raw.githubusercontent.com/cunnie/sslip.io/main/k8s/document_root_sslip.io/index.html
|
for HOST in ns-{aws,azure,gce,hetzner,ovh}.sslip.io; do
|
||||||
ssh ns-azure.sslip.io curl -L -o /var/nginx/sslip.io/index.html https://raw.githubusercontent.com/cunnie/sslip.io/main/k8s/document_root_sslip.io/index.html
|
ssh $HOST curl -L -o /var/nginx/sslip.io/index.html https://raw.githubusercontent.com/cunnie/sslip.io/main/k8s/document_root_sslip.io/index.html
|
||||||
|
done
|
||||||
```
|
```
|
||||||
|
|
||||||
Browse to <https://ci.nono.io/teams/main/pipelines/sslip.io> and check that everything is green.
|
Browse to <https://ci.nono.io/teams/main/pipelines/sslip.io> and check that everything is green.
|
||||||
|
@@ -76,7 +76,7 @@ var _ = Describe("speed", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(bytesRead).To(Equal(52)) // The A record response "127.0.0.1" is 52 bytes
|
Expect(bytesRead).To(Equal(52)) // The A record response "127.0.0.1" is 52 bytes
|
||||||
}
|
}
|
||||||
elapsedSeconds := time.Now().Sub(startTime).Seconds()
|
elapsedSeconds := time.Since(startTime).Seconds()
|
||||||
Eventually(serverSession.Err).Should(Say(`TypeA 127-0-0-1\.sslip\.io\. \? 127\.0\.0\.1`))
|
Eventually(serverSession.Err).Should(Say(`TypeA 127-0-0-1\.sslip\.io\. \? 127\.0\.0\.1`))
|
||||||
//fmt.Fprintf(os.Stderr, "Queries/second: %.2f\n", float64(numQueries)/elapsedSeconds)
|
//fmt.Fprintf(os.Stderr, "Queries/second: %.2f\n", float64(numQueries)/elapsedSeconds)
|
||||||
Expect(float64(numQueries) / elapsedSeconds).Should(BeNumerically(">", minThroughput))
|
Expect(float64(numQueries) / elapsedSeconds).Should(BeNumerically(">", minThroughput))
|
||||||
|
@@ -558,15 +558,13 @@ func squatOnTcp(port int) (squatters []net.Listener, err error) {
|
|||||||
squatters = append(squatters, squatter)
|
squatters = append(squatters, squatter)
|
||||||
}
|
}
|
||||||
addrCIDRs, err := net.InterfaceAddrs() // typical addrCIDR "10.9.9.161/24"
|
addrCIDRs, err := net.InterfaceAddrs() // typical addrCIDR "10.9.9.161/24"
|
||||||
|
ipv6regex := regexp.MustCompile(`:`)
|
||||||
for _, addrCIDR := range addrCIDRs {
|
for _, addrCIDR := range addrCIDRs {
|
||||||
ip, _, err := net.ParseCIDR(addrCIDR.String())
|
ip, _, err := net.ParseCIDR(addrCIDR.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return squatters, err
|
return squatters, err
|
||||||
}
|
}
|
||||||
ipv6, err := regexp.MatchString(`:`, addrCIDR.String())
|
ipv6 := ipv6regex.MatchString(addrCIDR.String())
|
||||||
if err != nil {
|
|
||||||
return squatters, err
|
|
||||||
}
|
|
||||||
// accommodate IPv6's requirements for brackets: "[::1]:1024" vs "127.0.0.1:1024"
|
// accommodate IPv6's requirements for brackets: "[::1]:1024" vs "127.0.0.1:1024"
|
||||||
if ipv6 {
|
if ipv6 {
|
||||||
squatter, err = net.Listen("tcp", "["+ip.String()+"]"+":"+strconv.Itoa(port))
|
squatter, err = net.Listen("tcp", "["+ip.String()+"]"+":"+strconv.Itoa(port))
|
||||||
|
12
main.go
12
main.go
@@ -144,6 +144,10 @@ func readFromUDP(conn *net.UDPConn, x *xip.Xip, quiet bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err = conn.WriteToUDP(response, addr)
|
_, err = conn.WriteToUDP(response, addr)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
if !quiet {
|
if !quiet {
|
||||||
log.Printf("%v.%d %s", addr.IP, addr.Port, logMessage)
|
log.Printf("%v.%d %s", addr.IP, addr.Port, logMessage)
|
||||||
}
|
}
|
||||||
@@ -168,6 +172,10 @@ func readFromTCP(tcpListener *net.TCPListener, x *xip.Xip, quiet bool) {
|
|||||||
}
|
}
|
||||||
remoteAddrPort := tcpConn.RemoteAddr().String()
|
remoteAddrPort := tcpConn.RemoteAddr().String()
|
||||||
addr, port, err := net.SplitHostPort(remoteAddrPort)
|
addr, port, err := net.SplitHostPort(remoteAddrPort)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer func(tcpConn *net.TCPConn) {
|
defer func(tcpConn *net.TCPConn) {
|
||||||
@@ -184,6 +192,10 @@ func readFromTCP(tcpListener *net.TCPListener, x *xip.Xip, quiet bool) {
|
|||||||
binary.BigEndian.PutUint16(responseSizeBigEndianBytes, responseSize)
|
binary.BigEndian.PutUint16(responseSizeBigEndianBytes, responseSize)
|
||||||
response = append(responseSizeBigEndianBytes, response...)
|
response = append(responseSizeBigEndianBytes, response...)
|
||||||
_, err = tcpConn.Write(response)
|
_, err = tcpConn.Write(response)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
if !quiet {
|
if !quiet {
|
||||||
log.Printf("%s.%s %s", addr, port, logMessage)
|
log.Printf("%s.%s %s", addr, port, logMessage)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user