package ocpp import ( "context" "encoding/base64" "net/http" ) // Proxy mode reuses the Session read loops (session.go) to pump frames between // the charger and Anker's cloud while tapping status and injecting our own // control calls. This file only provides the upstream dialer and auth helpers; // the CSMS is handed the already-dialed upstream connection via Accept. // DialUpstream opens a client OCPP 1.6J connection to an upstream CSMS (Anker's // cloud) for proxy mode. authHeader, when non-empty, is sent as the Authorization // request header (OCPP security profile 1 Basic auth). func DialUpstream(ctx context.Context, url, authHeader string) (*Conn, error) { h := http.Header{} if authHeader != "" { h.Set("Authorization", authHeader) } return Dial(ctx, url, []string{"ocpp1.6"}, h) } // BasicAuthHeader builds an HTTP Basic Authorization header value. func BasicAuthHeader(user, pass string) string { return "Basic " + base64.StdEncoding.EncodeToString([]byte(user+":"+pass)) }