Merge branch 'mikesir87-128-replace-underscores-in-urls'
This commit is contained in:
4
api.go
4
api.go
@@ -60,8 +60,8 @@ func main() {
|
||||
corsHandler := gh.CORS(gh.AllowCredentials(), gh.AllowedHeaders([]string{"x-requested-with", "content-type"}), gh.AllowedOrigins([]string{"*"}))
|
||||
|
||||
// Specific routes
|
||||
r.Host(`{subdomain:.*}{node:pwd[0-9]{1,3}_[0-9]{1,3}_[0-9]{1,3}_[0-9]{1,3}}-{port:[0-9]*}.{tld:.*}`).Handler(tcpHandler)
|
||||
r.Host(`{subdomain:.*}{node:pwd[0-9]{1,3}_[0-9]{1,3}_[0-9]{1,3}_[0-9]{1,3}}.{tld:.*}`).Handler(tcpHandler)
|
||||
r.Host(`{subdomain:.*}{node:pwd[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}}-{port:[0-9]*}.{tld:.*}`).Handler(tcpHandler)
|
||||
r.Host(`{subdomain:.*}{node:pwd[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}}.{tld:.*}`).Handler(tcpHandler)
|
||||
r.Host(`pwd{alias:.*}-{session:.*}-{port:[0-9]*}.{tld:.*}`).Handler(tcpHandler)
|
||||
r.Host(`pwd{alias:.*}-{session:.*}.{tld:.*}`).Handler(tcpHandler)
|
||||
r.HandleFunc("/ping", handlers.Ping).Methods("GET")
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"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(.*?)-(.*?)[\.-].*`)
|
||||
|
||||
func DnsRequest(w dns.ResponseWriter, r *dns.Msg) {
|
||||
@@ -22,7 +22,7 @@ func DnsRequest(w dns.ResponseWriter, r *dns.Msg) {
|
||||
match := dnsFilter.FindStringSubmatch(question)
|
||||
|
||||
tldChunks := strings.Split(match[1], "-")
|
||||
ip := strings.Replace(tldChunks[0], "_", ".", -1)
|
||||
ip := strings.Replace(tldChunks[0], "-", ".", -1)
|
||||
|
||||
m := new(dns.Msg)
|
||||
m.SetReply(r)
|
||||
|
||||
@@ -38,7 +38,7 @@ func getTargetInfo(vars map[string]string, req *http.Request) (string, string) {
|
||||
|
||||
if strings.HasPrefix(node, "pwd") {
|
||||
// Node is actually an ip, need to convert underscores by dots.
|
||||
ip := strings.Replace(strings.TrimPrefix(node, "pwd"), "_", ".", -1)
|
||||
ip := strings.Replace(strings.TrimPrefix(node, "pwd"), "-", ".", -1)
|
||||
|
||||
if net.ParseIP(ip) == nil {
|
||||
// Not a valid IP, so treat this is a hostname.
|
||||
@@ -143,7 +143,7 @@ func NewSSLDaemonHandler() http.Handler {
|
||||
node := v["node"]
|
||||
if strings.HasPrefix(node, "pwd") {
|
||||
// Node is actually an ip, need to convert underscores by dots.
|
||||
ip := strings.Replace(strings.TrimPrefix(node, "pwd"), "_", ".", -1)
|
||||
ip := strings.Replace(strings.TrimPrefix(node, "pwd"), "-", ".", -1)
|
||||
|
||||
if net.ParseIP(ip) == nil {
|
||||
// Not a valid IP, so treat this is a hostname.
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
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))
|
||||
log.Println("Listening on port " + port)
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
}
|
||||
|
||||
$scope.getProxyUrl = function(instance, port) {
|
||||
var url = window.location.protocol + '//pwd' + instance.ip.replace(/\./g, '_') + '-' + port + '.' + window.location.host;
|
||||
var url = window.location.protocol + '//pwd' + instance.ip.replace(/\./g, '-') + '-' + port + '.' + window.location.host;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user