mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-07-23 18:34:14 +00:00
Support port in domain
This commit is contained in:
parent
bcb11ad45f
commit
f2195fa9d6
1 changed files with 9 additions and 3 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/main/commands/base"
|
"github.com/xtls/xray-core/main/commands/base"
|
||||||
|
@ -38,8 +39,13 @@ func executePing(cmd *base.Command, args []string) {
|
||||||
base.Fatalf("domain not specified")
|
base.Fatalf("domain not specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
domain := cmdPing.Flag.Arg(0)
|
domainWithPort := cmdPing.Flag.Arg(0)
|
||||||
fmt.Println("Tls ping: ", domain)
|
fmt.Println("Tls ping: ", domainWithPort)
|
||||||
|
TargetPort := 443
|
||||||
|
domain, port, err := net.SplitHostPort(domainWithPort)
|
||||||
|
if err == nil {
|
||||||
|
TargetPort, _ = strconv.Atoi(port)
|
||||||
|
}
|
||||||
|
|
||||||
var ip net.IP
|
var ip net.IP
|
||||||
if len(*pingIPStr) > 0 {
|
if len(*pingIPStr) > 0 {
|
||||||
|
@ -60,7 +66,7 @@ func executePing(cmd *base.Command, args []string) {
|
||||||
fmt.Println("-------------------")
|
fmt.Println("-------------------")
|
||||||
fmt.Println("Pinging without SNI")
|
fmt.Println("Pinging without SNI")
|
||||||
{
|
{
|
||||||
tcpConn, err := net.DialTCP("tcp", nil, &net.TCPAddr{IP: ip, Port: 443})
|
tcpConn, err := net.DialTCP("tcp", nil, &net.TCPAddr{IP: ip, Port: TargetPort})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
base.Fatalf("Failed to dial tcp: %s", err)
|
base.Fatalf("Failed to dial tcp: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue