mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-11 17:47:20 +10:00
fix(ccm,ocm): allow reverse connector credentials to serve local requests
Connector mode credentials were unconditionally blocked from local use by unavailableError(), despite having a working forwardHTTPClient. Also set credentialDialer in OCM connector mode to prevent nil panic in WebSocket handler.
This commit is contained in:
@@ -372,9 +372,6 @@ func (c *externalCredential) earliestReset() time.Time {
|
||||
}
|
||||
|
||||
func (c *externalCredential) unavailableError() error {
|
||||
if c.reverse && c.connectorURL != nil {
|
||||
return E.New("credential ", c.tag, " is unavailable: reverse connector credentials cannot serve local requests")
|
||||
}
|
||||
if c.baseURL == reverseProxyBaseURL {
|
||||
session := c.getReverseSession()
|
||||
if session == nil || session.IsClosed() {
|
||||
|
||||
@@ -197,6 +197,7 @@ func newExternalCredential(ctx context.Context, tag string, options option.OCMEx
|
||||
|
||||
if options.Reverse {
|
||||
// Connector mode: we dial out to serve, not to proxy
|
||||
credential.credentialDialer = credentialDialer
|
||||
credential.connectorDialer = credentialDialer
|
||||
if options.Server != "" {
|
||||
credential.connectorDestination = M.ParseSocksaddrHostPort(options.Server, externalCredentialServerPort(parsedURL, options.ServerPort))
|
||||
@@ -407,9 +408,6 @@ func (c *externalCredential) earliestReset() time.Time {
|
||||
}
|
||||
|
||||
func (c *externalCredential) unavailableError() error {
|
||||
if c.reverse && c.connectorURL != nil {
|
||||
return E.New("credential ", c.tag, " is unavailable: reverse connector credentials cannot serve local requests")
|
||||
}
|
||||
if c.baseURL == reverseProxyBaseURL {
|
||||
session := c.getReverseSession()
|
||||
if session == nil || session.IsClosed() {
|
||||
|
||||
Reference in New Issue
Block a user