Fix missing spots due to host url change
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/play-with-docker/play-with-docker/services"
|
"github.com/play-with-docker/play-with-docker/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dnsFilter = regexp.MustCompile(`^.*pwd([0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}(?:-[0-9]{1,5})?)\..*$`)
|
var dnsFilter = regexp.MustCompile(`^.*pwd([0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3})(?:-[0-9]{1,5})?\..*$`)
|
||||||
var aliasFilter = regexp.MustCompile(`^.*pwd(.*?)-(.*?)[\.-].*`)
|
var aliasFilter = regexp.MustCompile(`^.*pwd(.*?)-(.*?)[\.-].*`)
|
||||||
|
|
||||||
func DnsRequest(w dns.ResponseWriter, r *dns.Msg) {
|
func DnsRequest(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
@@ -21,8 +21,7 @@ func DnsRequest(w dns.ResponseWriter, r *dns.Msg) {
|
|||||||
|
|
||||||
match := dnsFilter.FindStringSubmatch(question)
|
match := dnsFilter.FindStringSubmatch(question)
|
||||||
|
|
||||||
tldChunks := strings.Split(match[1], "-")
|
ip := strings.Replace(match[1], "-", ".", -1)
|
||||||
ip := strings.Replace(tldChunks[0], "-", ".", -1)
|
|
||||||
|
|
||||||
m := new(dns.Msg)
|
m := new(dns.Msg)
|
||||||
m.SetReply(r)
|
m.SetReply(r)
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
vhost "github.com/inconshreveable/go-vhost"
|
vhost "github.com/inconshreveable/go-vhost"
|
||||||
"github.com/play-with-docker/play-with-docker/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartTLSProxy(port string) {
|
func StartTLSProxy(port string) {
|
||||||
var validProxyHost = regexp.MustCompile(`^.*pwd([0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}(?:-[0-9]{1,5})?)\..*$`)
|
var validProxyHost = regexp.MustCompile(`^.*pwd([0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3})(?:-?([0-9]{1,5}))?\..*$`)
|
||||||
|
|
||||||
tlsListener, tlsErr := net.Listen("tcp", fmt.Sprintf(":%s", port))
|
tlsListener, tlsErr := net.Listen("tcp", fmt.Sprintf(":%s", port))
|
||||||
log.Println("Listening on port " + port)
|
log.Println("Listening on port " + port)
|
||||||
@@ -40,10 +39,7 @@ func StartTLSProxy(port string) {
|
|||||||
|
|
||||||
host := vhostConn.ClientHelloMsg.ServerName
|
host := vhostConn.ClientHelloMsg.ServerName
|
||||||
match := validProxyHost.FindStringSubmatch(host)
|
match := validProxyHost.FindStringSubmatch(host)
|
||||||
if len(match) == 2 {
|
if len(match) < 2 {
|
||||||
// This is a valid proxy host, keep only the important part
|
|
||||||
host = match[1]
|
|
||||||
} else {
|
|
||||||
// Not a valid proxy host, just close connection.
|
// Not a valid proxy host, just close connection.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -51,17 +47,11 @@ func StartTLSProxy(port string) {
|
|||||||
var targetIP string
|
var targetIP string
|
||||||
targetPort := "443"
|
targetPort := "443"
|
||||||
|
|
||||||
hostPort := strings.Split(host, ":")
|
if len(match) == 3 {
|
||||||
if len(hostPort) > 1 && hostPort[1] != config.SSLPortNumber {
|
targetPort = match[2]
|
||||||
targetPort = hostPort[1]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target := strings.Split(hostPort[0], "-")
|
ip := strings.Replace(match[1], "-", ".", -1)
|
||||||
if len(target) > 1 {
|
|
||||||
targetPort = target[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
ip := strings.Replace(target[0], "_", ".", -1)
|
|
||||||
|
|
||||||
if net.ParseIP(ip) == nil {
|
if net.ParseIP(ip) == nil {
|
||||||
// Not a valid IP, so treat this is a hostname.
|
// Not a valid IP, so treat this is a hostname.
|
||||||
|
|||||||
Reference in New Issue
Block a user