embed default snowflake site

This commit is contained in:
idk
2022-03-04 12:40:25 -05:00
parent 9ac9a82482
commit 3a1bc74b4b
5 changed files with 139 additions and 3 deletions

View File

@ -4,6 +4,7 @@
package main
import (
"embed"
"flag"
"io"
"log"
@ -18,6 +19,11 @@ import (
sf "git.torproject.org/pluggable-transports/snowflake.git/proxy/lib"
)
//go:embed tor-browser/www/home.css
//go:embed tor-browser/www/index.html
//go:embed tor-browser/www/blizzard.png
var snowflakeContent embed.FS
var snowflakeProxy sf.SnowflakeProxy
var (
@ -64,7 +70,11 @@ func Snowflake() {
}
go func() {
http.Handle("/", http.FileServer(http.Dir(*snowflakeDirectory)))
if *directory != "" {
http.Handle("/", http.FileServer(http.Dir(*snowflakeDirectory)))
} else {
http.Handle("/", http.FileServer(http.FS(snowflakeContent)))
}
log.Printf("Serving %s on HTTP localhost:snowflakePort: %s\n", *snowflakeDirectory, *snowflakePort)
log.Fatal(http.ListenAndServe("localhost:"+*snowflakePort, nil))