nip/internal/agent/agent.go

22 lines
457 B
Go
Raw Permalink Normal View History

2024-08-25 18:57:31 +08:00
package agent
import (
"git.lovezsh.com/lovezsh/nip/internal/forward"
"git.lovezsh.com/lovezsh/nip/internal/pkg/httptunnel"
)
type Agent struct {
httptunnel *httptunnel.Server
}
func New(addr string, token string, server string) *Agent {
forwarder := forward.New(server, token)
return &Agent{
httptunnel: httptunnel.New(addr, forwarder.Forward),
}
}
func (agent *Agent) ListenAndServe() (err error) {
return agent.httptunnel.ListenAndServe()
}