feat: import Sea vHost single-server testing release

This commit is contained in:
canglan committed 2026-10-30 08:39:10 +08:00
commit 248badd33e
441 files changed
+63221

No files matched your search

+39
View File
@@ -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)
}
}
@@ -0,0 +1,41 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
public final class SeaVHostSmoke {
private SeaVHostSmoke() {}
public static void main(String[] args) throws Exception {
String portValue = System.getenv("PORT");
if (portValue == null || portValue.isEmpty()) {
for (String argument : args) {
if (argument.startsWith("--server.port=")) {
portValue = argument.substring("--server.port=".length());
}
}
}
if (portValue == null || portValue.isEmpty()) {
throw new IllegalArgumentException("missing runtime port");
}
int port = Integer.parseInt(portValue);
byte[] body = "sea-vhost-java-artifact".getBytes(StandardCharsets.UTF_8);
try (ServerSocket server = new ServerSocket(port, 50, InetAddress.getLoopbackAddress())) {
while (true) {
try (Socket socket = server.accept()) {
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.US_ASCII));
for (String line; (line = reader.readLine()) != null && !line.isEmpty();) {
// Consume one HTTP request before returning the fixed marker.
}
OutputStream output = socket.getOutputStream();
output.write(("HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: " + body.length + "\r\nConnection: close\r\n\r\n").getBytes(StandardCharsets.US_ASCII));
output.write(body);
output.flush();
}
}
}
}
}