Skip to content

Commit

Permalink
Rename config package (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna authored Sep 19, 2024
1 parent c550c0b commit 23989fe
Show file tree
Hide file tree
Showing 25 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion x/config/config.go → x/configurl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion x/config/config_test.go → x/configurl/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion x/config/dns.go → x/configurl/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion x/config/doc.go → x/configurl/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@ where wrapStreamDialerWithCustom and wrapPacketDialerWithCustom implement [NewPa
[Onion Routing]: https://en.wikipedia.org/wiki/Onion_routing
*/
package config
package configurl
2 changes: 1 addition & 1 deletion x/config/override.go → x/configurl/override.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion x/config/override_test.go → x/configurl/override_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"net/url"
Expand Down
2 changes: 1 addition & 1 deletion x/config/shadowsocks.go → x/configurl/shadowsocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"encoding/base64"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"encoding/base64"
Expand Down
2 changes: 1 addition & 1 deletion x/config/socks5.go → x/configurl/socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"net/url"
Expand Down
2 changes: 1 addition & 1 deletion x/config/split.go → x/configurl/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion x/config/tls.go → x/configurl/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion x/config/tls_test.go → x/configurl/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"net/url"
Expand Down
2 changes: 1 addition & 1 deletion x/config/websocket.go → x/configurl/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package config
package configurl

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions x/examples/fetch-speed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"strings"
"time"

"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
)

var debugLog log.Logger = *log.New(io.Discard, "", 0)
Expand Down Expand Up @@ -58,7 +58,7 @@ func main() {
os.Exit(1)
}

dialer, err := config.NewDefaultConfigToDialer().NewStreamDialer(*transportFlag)
dialer, err := configurl.NewDefaultConfigToDialer().NewStreamDialer(*transportFlag)
if err != nil {
log.Fatalf("Could not create dialer: %v\n", err)
}
Expand Down
4 changes: 2 additions & 2 deletions x/examples/fetch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"strings"
"time"

"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
)

var debugLog log.Logger = *log.New(io.Discard, "", 0)
Expand Down Expand Up @@ -84,7 +84,7 @@ func main() {
os.Exit(1)
}

dialer, err := config.NewDefaultConfigToDialer().NewStreamDialer(*transportFlag)
dialer, err := configurl.NewDefaultConfigToDialer().NewStreamDialer(*transportFlag)
if err != nil {
log.Fatalf("Could not create dialer: %v\n", err)
}
Expand Down
4 changes: 2 additions & 2 deletions x/examples/http2transport/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"os/signal"
"time"

"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
"github.com/Jigsaw-Code/outline-sdk/x/httpproxy"
)

Expand All @@ -34,7 +34,7 @@ func main() {
urlProxyPrefixFlag := flag.String("urlProxyPrefix", "/proxy", "Path where to run the URL proxy. Set to empty (\"\") to disable it.")
flag.Parse()

dialer, err := config.NewDefaultConfigToDialer().NewStreamDialer(*transportFlag)
dialer, err := configurl.NewDefaultConfigToDialer().NewStreamDialer(*transportFlag)

if err != nil {
log.Fatalf("Could not create dialer: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions x/examples/outline-cli/outline_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/Jigsaw-Code/outline-sdk/network"
"github.com/Jigsaw-Code/outline-sdk/network/lwip2transport"
"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
)

const (
Expand All @@ -39,7 +39,7 @@ type OutlineDevice struct {
svrIP net.IP
}

var configToDialer = config.NewDefaultConfigToDialer()
var configToDialer = configurl.NewDefaultConfigToDialer()

func NewOutlineDevice(transportConfig string) (od *OutlineDevice, err error) {
ip, err := resolveShadowsocksServerIPFromConfig(transportConfig)
Expand Down
4 changes: 2 additions & 2 deletions x/examples/outline-cli/outline_packet_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/Jigsaw-Code/outline-sdk/network"
"github.com/Jigsaw-Code/outline-sdk/network/dnstruncate"
"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
"github.com/Jigsaw-Code/outline-sdk/x/connectivity"
)

Expand All @@ -36,7 +36,7 @@ type outlinePacketProxy struct {
func newOutlinePacketProxy(transportConfig string) (opp *outlinePacketProxy, err error) {
opp = &outlinePacketProxy{}

if opp.remotePl, err = config.NewPacketListener(transportConfig); err != nil {
if opp.remotePl, err = configurl.NewPacketListener(transportConfig); err != nil {
return nil, fmt.Errorf("failed to create UDP packet listener: %w", err)
}
if opp.remote, err = network.NewPacketProxyFromPacketListener(opp.remotePl); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions x/examples/resolve/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"time"

"github.com/Jigsaw-Code/outline-sdk/dns"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
"golang.org/x/net/dns/dnsmessage"
)

Expand Down Expand Up @@ -66,7 +66,7 @@ func main() {
resolverAddr := *resolverFlag

var resolver dns.Resolver
configToDialer := config.NewDefaultConfigToDialer()
configToDialer := configurl.NewDefaultConfigToDialer()
if *tcpFlag {
streamDialer, err := configToDialer.NewStreamDialer(*transportFlag)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions x/examples/smart-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"time"

"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
"github.com/Jigsaw-Code/outline-sdk/x/httpproxy"
"github.com/Jigsaw-Code/outline-sdk/x/smart"
)
Expand Down Expand Up @@ -86,7 +86,7 @@ func main() {
log.Fatalf("Could not read config: %v", err)
}

configToDialer := config.NewDefaultConfigToDialer()
configToDialer := configurl.NewDefaultConfigToDialer()
packetDialer, err := configToDialer.NewPacketDialer(*transportFlag)
if err != nil {
log.Fatalf("Could not create packet dialer: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions x/examples/test-connectivity/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"time"

"github.com/Jigsaw-Code/outline-sdk/dns"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
"github.com/Jigsaw-Code/outline-sdk/x/connectivity"
"github.com/Jigsaw-Code/outline-sdk/x/report"
)
Expand Down Expand Up @@ -161,7 +161,7 @@ func main() {
success := false
jsonEncoder := json.NewEncoder(os.Stdout)
jsonEncoder.SetEscapeHTML(false)
configToDialer := config.NewDefaultConfigToDialer()
configToDialer := configurl.NewDefaultConfigToDialer()
for _, resolverHost := range strings.Split(*resolverFlag, ",") {
resolverHost := strings.TrimSpace(resolverHost)
resolverAddress := net.JoinHostPort(resolverHost, "53")
Expand Down Expand Up @@ -194,7 +194,7 @@ func main() {
success = true
}
debugLog.Printf("Test %v %v result: %v", proto, resolverAddress, result)
sanitizedConfig, err := config.SanitizeConfig(*transportFlag)
sanitizedConfig, err := configurl.SanitizeConfig(*transportFlag)
if err != nil {
log.Fatalf("Failed to sanitize config: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions x/examples/ws2endpoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"time"

"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
"golang.org/x/net/websocket"
)

Expand Down Expand Up @@ -60,7 +60,7 @@ func main() {
defer listener.Close()
log.Printf("Proxy listening on %v\n", listener.Addr().String())

config2Dialer := config.NewDefaultConfigToDialer()
config2Dialer := configurl.NewDefaultConfigToDialer()
mux := http.NewServeMux()
if *tcpPathFlag != "" {
dialer, err := config2Dialer.NewStreamDialer(*transportFlag)
Expand Down
8 changes: 4 additions & 4 deletions x/httpproxy/connect_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"strings"

"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
)

type sanitizeErrorDialer struct {
Expand Down Expand Up @@ -52,7 +52,7 @@ func (d *sanitizeErrorDialer) DialStream(ctx context.Context, addr string) (tran

type connectHandler struct {
dialer *sanitizeErrorDialer
dialerConfig *config.ConfigToDialer
dialerConfig *configurl.ConfigToDialer
}

var _ http.Handler = (*connectHandler)(nil)
Expand Down Expand Up @@ -140,7 +140,7 @@ func (h *connectHandler) ServeHTTP(proxyResp http.ResponseWriter, proxyReq *http
// the requests using the given [transport.StreamDialer].
//
// Clients can specify a Transport header with a value of a transport config as specified in
// the [config] package to specify the transport for a given request.
// the [configurl] package to specify the transport for a given request.
//
// The resulting handler is currently vulnerable to probing attacks. It's ok as a localhost proxy
// but it may be vulnerable if used as a public proxy.
Expand All @@ -149,7 +149,7 @@ func NewConnectHandler(dialer transport.StreamDialer) http.Handler {
// of the base dialer (e.g. access key credentials) to the user.
sd := &sanitizeErrorDialer{dialer}
// TODO(fortuna): Inject the config parser
dialerConfig := config.NewDefaultConfigToDialer()
dialerConfig := configurl.NewDefaultConfigToDialer()
dialerConfig.BaseStreamDialer = sd
return &connectHandler{sd, dialerConfig}
}
4 changes: 2 additions & 2 deletions x/mobileproxy/mobileproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"time"

"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
"github.com/Jigsaw-Code/outline-sdk/x/httpproxy"
"github.com/Jigsaw-Code/outline-sdk/x/smart"
)
Expand Down Expand Up @@ -152,7 +152,7 @@ type StreamDialer struct {
transport.StreamDialer
}

var configToDialer = config.NewDefaultConfigToDialer()
var configToDialer = configurl.NewDefaultConfigToDialer()

// NewStreamDialerFromConfig creates a [StreamDialer] based on the given config.
// The config format is specified in https://pkg.go.dev/github.com/Jigsaw-Code/outline-sdk/x/config#hdr-Config_Format.
Expand Down
4 changes: 2 additions & 2 deletions x/smart/stream_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/Jigsaw-Code/outline-sdk/dns"
"github.com/Jigsaw-Code/outline-sdk/transport"
"github.com/Jigsaw-Code/outline-sdk/x/config"
"github.com/Jigsaw-Code/outline-sdk/x/configurl"
)

// To test one strategy:
Expand Down Expand Up @@ -231,7 +231,7 @@ func (f *StrategyFinder) findTLS(ctx context.Context, testDomains []string, base
if len(tlsConfig) == 0 {
return nil, errors.New("config for TLS is empty. Please specify at least one transport")
}
var configToDialer = config.NewDefaultConfigToDialer()
var configToDialer = configurl.NewDefaultConfigToDialer()
configToDialer.BaseStreamDialer = baseDialer

ctx, searchDone := context.WithCancel(ctx)
Expand Down

0 comments on commit 23989fe

Please sign in to comment.