mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-25 10:52:48 +01:00
- Add `StreamPort` configuration to agent configuration and environment variables - Implement TCP and UDP stream client support in agent package - Update agent verification to test stream connectivity (TCP/UDP) - Add `/info` endpoint to agent HTTP handler for version, name, runtime, and stream port - Remove /version, /name, /runtime APIs, replaced by /info - Update agent compose template to expose stream port for TCP and UDP - Update agent creation API to optionally specify stream port (defaults to port + 1) - Modify `StreamRoute` to pass agent configuration to stream implementations - Update `TCPTCPStream` and `UDPUDPStream` to use agent stream tunneling when agent is configured - Add support for both direct connections and agent-tunneled connections in stream routes This enables agents to handle TCP and UDP route tunneling, expanding the proxy capabilities beyond HTTP-only connections.
35 lines
954 B
Go
35 lines
954 B
Go
package agent
|
|
|
|
import (
|
|
"bytes"
|
|
"text/template"
|
|
)
|
|
|
|
var (
|
|
installScript = `AGENT_NAME="{{.Name}}" \
|
|
AGENT_PORT="{{.Port}}" \
|
|
AGENT_STREAM_PORT="{{.StreamPort}}" \
|
|
AGENT_CA_CERT="{{.CACert}}" \
|
|
AGENT_SSL_CERT="{{.SSLCert}}" \
|
|
{{ if eq .ContainerRuntime "nerdctl" -}}
|
|
DOCKER_SOCKET="/var/run/containerd/containerd.sock" \
|
|
RUNTIME="nerdctl" \
|
|
{{ else if eq .ContainerRuntime "podman" -}}
|
|
DOCKER_SOCKET="/var/run/podman/podman.sock" \
|
|
RUNTIME="podman" \
|
|
{{ else -}}
|
|
DOCKER_SOCKET="/var/run/docker.sock" \
|
|
RUNTIME="docker" \
|
|
{{ end -}}
|
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/yusing/godoxy/main/scripts/install-agent.sh)"`
|
|
installScriptTemplate = template.Must(template.New("install.sh").Parse(installScript))
|
|
)
|
|
|
|
func (c *AgentEnvConfig) Generate() (string, error) {
|
|
buf := bytes.NewBuffer(make([]byte, 0, 4096))
|
|
if err := installScriptTemplate.Execute(buf, c); err != nil {
|
|
return "", err
|
|
}
|
|
return buf.String(), nil
|
|
}
|