Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS config custom clone #264

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions fastdialer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,36 @@ package fastdialer
import (
"crypto/tls"

"github.com/ulule/deepcopier"
ztls "github.com/zmap/zcrypto/tls"
"golang.org/x/net/idna"
)

func AsTLSConfig(ztlsConfig *ztls.Config) (*tls.Config, error) {
tlsConfig := &tls.Config{}
err := deepcopier.Copy(ztlsConfig).To(tlsConfig)
return tlsConfig, err
tlsConfig := &tls.Config{
NextProtos: ztlsConfig.NextProtos,
ServerName: ztlsConfig.ServerName,
ClientAuth: tls.ClientAuthType(ztlsConfig.ClientAuth),
InsecureSkipVerify: ztlsConfig.InsecureSkipVerify,
CipherSuites: ztlsConfig.CipherSuites,
SessionTicketsDisabled: ztlsConfig.SessionTicketsDisabled,
MinVersion: ztlsConfig.MinVersion,
MaxVersion: ztlsConfig.MaxVersion,
}
return tlsConfig, nil
}

func AsZTLSConfig(tlsConfig *tls.Config) (*ztls.Config, error) {
ztlsConfig := &ztls.Config{}
err := deepcopier.Copy(tlsConfig).To(ztlsConfig)
return ztlsConfig, err
ztlsConfig := &ztls.Config{
NextProtos: tlsConfig.NextProtos,
ServerName: tlsConfig.ServerName,
ClientAuth: ztls.ClientAuthType(tlsConfig.ClientAuth),
InsecureSkipVerify: tlsConfig.InsecureSkipVerify,
CipherSuites: tlsConfig.CipherSuites,
SessionTicketsDisabled: tlsConfig.SessionTicketsDisabled,
MinVersion: tlsConfig.MinVersion,
MaxVersion: tlsConfig.MaxVersion,
}
return ztlsConfig, nil
}

func IsTLS13(config interface{}) bool {
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/projectdiscovery/utils v0.0.80
github.com/refraction-networking/utls v1.5.4
github.com/stretchr/testify v1.8.4
github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6
github.com/zmap/zcrypto v0.0.0-20230422215203-9a665e1e9968
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db
golang.org/x/net v0.17.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ github.com/tidwall/rtred v0.1.2 h1:exmoQtOLvDoO8ud++6LwVsAMTu0KPzLTUrMln8u1yu8=
github.com/tidwall/rtred v0.1.2/go.mod h1:hd69WNXQ5RP9vHd7dqekAz+RIdtfBogmglkZSRxCHFQ=
github.com/tidwall/tinyqueue v0.1.1 h1:SpNEvEggbpyN5DIReaJ2/1ndroY8iyEGxPYxoSaymYE=
github.com/tidwall/tinyqueue v0.1.1/go.mod h1:O/QNHwrnjqr6IHItYrzoHAKYhBkLI67Q096fQP5zMYw=
github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6 h1:TtyC78WMafNW8QFfv3TeP3yWNDG+uxNkk9vOrnDu6JA=
github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6/go.mod h1:h8272+G2omSmi30fBXiZDMkmHuOgonplfKIKjQWzlfs=
github.com/weppos/publicsuffix-go v0.13.0/go.mod h1:z3LCPQ38eedDQSwmsSRW4Y7t2L8Ln16JPQ02lHAdn5k=
github.com/weppos/publicsuffix-go v0.30.1-0.20230422193905-8fecedd899db h1:/WcxBne+5CbtbgWd/sV2wbravmr4sT7y52ifQaCgoLs=
github.com/weppos/publicsuffix-go v0.30.1-0.20230422193905-8fecedd899db/go.mod h1:aiQaH1XpzIfgrJq3S1iw7w+3EDbRP7mF5fmwUhWyRUs=
Expand Down
Loading