-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from projectdiscovery/ztls-support
Add support for ztls
- Loading branch information
Showing
6 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package fastdialer | ||
|
||
import ( | ||
"crypto/tls" | ||
|
||
"github.com/ulule/deepcopier" | ||
ztls "github.com/zmap/zcrypto/tls" | ||
) | ||
|
||
func AsTLSConfig(ztlsConfig *ztls.Config) (*tls.Config, error) { | ||
tlsConfig := &tls.Config{} | ||
err := deepcopier.Copy(ztlsConfig).To(tlsConfig) | ||
return tlsConfig, err | ||
} | ||
|
||
func AsZTLSConfig(tlsConfig *tls.Config) (*ztls.Config, error) { | ||
ztlsConfig := &ztls.Config{} | ||
err := deepcopier.Copy(tlsConfig).To(ztlsConfig) | ||
return ztlsConfig, err | ||
} | ||
|
||
func IsTLS13(config interface{}) bool { | ||
switch c := config.(type) { | ||
case *tls.Config: | ||
return c.MinVersion == tls.VersionTLS13 | ||
case *ztls.Config: | ||
return c.MinVersion == tls.VersionTLS13 | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package fastdialer | ||
|
||
import ( | ||
"crypto/tls" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
ztls "github.com/zmap/zcrypto/tls" | ||
) | ||
|
||
func TestAsTLSConfig(t *testing.T) { | ||
ztlsConfig := &ztls.Config{} | ||
tlsConfig, err := AsTLSConfig(ztlsConfig) | ||
require.Nil(t, err) | ||
require.NotNil(t, tlsConfig) | ||
} | ||
|
||
func TestAsZTLSConfig(t *testing.T) { | ||
tlsConfig := &tls.Config{} | ||
ztlsConfig, err := AsZTLSConfig(tlsConfig) | ||
require.Nil(t, err) | ||
require.NotNil(t, ztlsConfig) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters