feat: import Sea vHost single-server testing release
This commit is contained in:
commit
248badd33e
441 files changed
+63221
No files matched your search
@@ -0,0 +1,39 @@
|
||||
//go:build linux && amd64
|
||||
|
||||
// This deliberately small HTTP server is the real Go artifact used by the
|
||||
// aaPanel lifecycle smoke test. It avoids third-party dependencies so the
|
||||
// binary can fit into even the smallest development quota.
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func main() {
|
||||
port, err := strconv.Atoi(os.Getenv("PORT"))
|
||||
if err != nil || port < 1 || port > 65535 {
|
||||
os.Exit(2)
|
||||
}
|
||||
listener, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, 0)
|
||||
if err != nil {
|
||||
os.Exit(3)
|
||||
}
|
||||
defer syscall.Close(listener)
|
||||
_ = syscall.SetsockoptInt(listener, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
|
||||
if syscall.Bind(listener, &syscall.SockaddrInet4{Port: port, Addr: [4]byte{127, 0, 0, 1}}) != nil || syscall.Listen(listener, 16) != nil {
|
||||
os.Exit(4)
|
||||
}
|
||||
response := []byte("HTTP/1.1 200 OK\r\nContent-Length: 21\r\nConnection: close\r\n\r\nsea-vhost-go-artifact")
|
||||
for {
|
||||
connection, _, acceptErr := syscall.Accept(listener)
|
||||
if acceptErr != nil {
|
||||
continue
|
||||
}
|
||||
var request [1024]byte
|
||||
_, _ = syscall.Read(connection, request[:])
|
||||
_, _ = syscall.Write(connection, response)
|
||||
_ = syscall.Close(connection)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user