Build it and ship it LUL
This commit is contained in:
parent
419dc2a670
commit
8d4abeba41
1 changed files with 17 additions and 2 deletions
19
main.go
19
main.go
|
@ -13,6 +13,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
"flag"
|
||||||
|
|
||||||
"github.com/kolesa-team/go-webp/encoder"
|
"github.com/kolesa-team/go-webp/encoder"
|
||||||
"github.com/kolesa-team/go-webp/webp"
|
"github.com/kolesa-team/go-webp/webp"
|
||||||
|
@ -51,7 +52,7 @@ var h2client = &http.Client{
|
||||||
}
|
}
|
||||||
|
|
||||||
// user agent to use
|
// user agent to use
|
||||||
var ua = "Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101"
|
var ua = "Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101"
|
||||||
|
|
||||||
var allowed_hosts = []string{
|
var allowed_hosts = []string{
|
||||||
"youtube.com",
|
"youtube.com",
|
||||||
|
@ -300,12 +301,26 @@ func RelativeUrl(in string) (newurl string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var sock string
|
||||||
|
|
||||||
path_prefix = os.Getenv("PREFIX_PATH")
|
path_prefix = os.Getenv("PREFIX_PATH")
|
||||||
|
|
||||||
disable_ipv6 = os.Getenv("DISABLE_IPV6") == "1"
|
disable_ipv6 = os.Getenv("DISABLE_IPV6") == "1"
|
||||||
disable_webp = os.Getenv("DISABLE_WEBP") == "1"
|
disable_webp = os.Getenv("DISABLE_WEBP") == "1"
|
||||||
|
|
||||||
socket := "socket" + string(os.PathSeparator) + "http-proxy.sock"
|
if _, err := os.Stat("socket"); os.IsNotExist(err) {
|
||||||
|
fmt.Println("socket folder doesn't exists, creating one now.")
|
||||||
|
err = os.Mkdir("socket", 0755)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Failed to create folder, error:")
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flag.StringVar(&sock, "s", "http-proxy.sock", "Specify a socket name")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
socket := "socket" + string(os.PathSeparator) + string(sock)
|
||||||
syscall.Unlink(socket)
|
syscall.Unlink(socket)
|
||||||
listener, err := net.Listen("unix", socket)
|
listener, err := net.Listen("unix", socket)
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
|
|
Loading…
Reference in a new issue