Peter Kurfer
a720b0ee41
* supports HTTP * support TLS interception e.g. for HTTPS * support CA generation via cli * first draft of plugin API * support commands from plugins * includes Dockerfile * includes basic configuration
20 lines
424 B
Go
20 lines
424 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
ipExtractionRegex = regexp.MustCompile(`(.+):\d{1,5}$`)
|
|
)
|
|
|
|
func extractIPFromAddress(addr string) (string, error) {
|
|
matches := ipExtractionRegex.FindAllStringSubmatch(addr, -1)
|
|
if len(matches) > 0 && len(matches[0]) >= 1 {
|
|
return strings.Trim(matches[0][1], "[]"), nil
|
|
} else {
|
|
return "", fmt.Errorf("failed to extract IP address from addr %s", addr)
|
|
}
|
|
}
|