mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-08-09 22:57:47 +02:00
Refactorized main entry function
- Moved constants to def.go - Added acme close function (not used for now) - Added robots.txt to prevent webmin panel being scanned by search engine
This commit is contained in:
@@ -9,6 +9,7 @@ package domainsniff
|
||||
|
||||
*/
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
@@ -25,6 +26,30 @@ func DomainReachableWithError(domain string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check if a domain have TLS but it is self-signed or expired
|
||||
func DomainIsSelfSigned(domain string) (bool, error) {
|
||||
//Get the certificate
|
||||
conn, err := net.Dial("tcp", domain)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
//Connect with TLS using insecure skip verify
|
||||
config := &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
tlsConn := tls.Client(conn, config)
|
||||
err = tlsConn.Handshake()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
//Check if the certificate is self-signed
|
||||
cert := tlsConn.ConnectionState().PeerCertificates[0]
|
||||
return cert.Issuer.CommonName == cert.Subject.CommonName, nil
|
||||
}
|
||||
|
||||
// Check if domain reachable
|
||||
func DomainReachable(domain string) bool {
|
||||
return DomainReachableWithError(domain) == nil
|
||||
|
Reference in New Issue
Block a user