build(deps): add ent and x libs dependencies

This commit is contained in:
dalbodeule
2025-11-26 16:32:54 +09:00
parent 98bc949db1
commit 4d5b7f15f3
19 changed files with 1111 additions and 0 deletions

19
internal/proxy/client.go Normal file
View File

@@ -0,0 +1,19 @@
package proxy
import (
"context"
"net/http"
)
// ClientProxy 는 서버로부터 받은 요청을 로컬 HTTP 서비스로 전달하는 클라이언트 측 프록시입니다.
type ClientProxy struct {
HTTPClient *http.Client
}
// StartLoop 는 DTLS 세션에서 protocol.Request 를 읽고 로컬 HTTP 요청을 수행한 뒤
// protocol.Response 를 다시 세션으로 쓰는 루프를 의미합니다.
// 실제 구현은 dtls.Session, protocol.{Request,Response} 를 조합해 작성합니다.
func (p *ClientProxy) StartLoop(ctx context.Context) error {
// TODO: DTLS 세션 읽기/쓰기 및 로컬 HTTP 호출 구현
return nil
}

43
internal/proxy/server.go Normal file
View File

@@ -0,0 +1,43 @@
package proxy
import (
"context"
"net/http"
"golang.org/x/net/http2"
)
// ServerProxy 는 공인 HTTP(S) 엔드포인트에서 들어오는 요청을
// 적절한 클라이언트로 라우팅하는 서버 측 프록시입니다.
type ServerProxy struct {
Router Router
HTTPServer *http.Server
}
// Router 는 도메인/패스 기준으로 어떤 클라이언트/서비스로 보낼지 결정하는 인터페이스입니다.
type Router interface {
Route(req *http.Request) (clientID string, serviceName string, err error)
}
// NewHTTPServer 는 H1/H2 를 지원하는 기본 HTTP 서버를 생성합니다.
func NewHTTPServer(addr string, handler http.Handler) *http.Server {
srv := &http.Server{
Addr: addr,
Handler: handler,
}
http2.ConfigureServer(srv, &http2.Server{})
return srv
}
// Start / Shutdown 등은 추후 구현합니다.
func (p *ServerProxy) Start(ctx context.Context) error {
// TODO: HTTP/HTTPS 리스너 시작 및 DTLS 연동
return nil
}
func (p *ServerProxy) Shutdown(ctx context.Context) error {
if p.HTTPServer != nil {
return p.HTTPServer.Shutdown(ctx)
}
return nil
}