From 13d6a492a8f7f184e426b422e162263285bd9da7 Mon Sep 17 00:00:00 2001 From: codeskyblue Date: Wed, 27 Jul 2016 23:26:52 +0800 Subject: [PATCH] add plist proxy --- httpstaticserver.go | 10 ++++++++++ main.go | 22 +++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/httpstaticserver.go b/httpstaticserver.go index 08dd016..8872662 100644 --- a/httpstaticserver.go +++ b/httpstaticserver.go @@ -38,6 +38,7 @@ func NewHTTPStaticServer(root string) *HTTPStaticServer { // routers for Apple *.ipa m.HandleFunc("/-/ipa/icon/{path:.*}", s.hIpaIcon) m.HandleFunc("/-/ipa/plist/{path:.*}", s.hPlist) + m.HandleFunc("/-/ipa/link/{path:.*}", s.hIpaLink) // TODO: /ipa/link, /ipa/info m.HandleFunc("/{path:.*}", s.hIndex).Methods("GET") @@ -160,6 +161,15 @@ func (s *HTTPStaticServer) hPlist(w http.ResponseWriter, r *http.Request) { w.Write(data) } +func (s *HTTPStaticServer) hIpaLink(w http.ResponseWriter, r *http.Request) { + // need ua_parser + w.Write([]byte("redirect to itms service")) // url need urjJoin if setted plist proxy + + // WeChat need to tell to open with Safari + + // Browser just tell not supported. +} + func (s *HTTPStaticServer) hFileOrDirectory(w http.ResponseWriter, r *http.Request) { path := mux.Vars(r)["path"] log.Println("Path:", s.Root, path) diff --git a/main.go b/main.go index 0976478..428c535 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "log" "net/http" + "net/url" "strconv" "strings" @@ -12,15 +13,16 @@ import ( ) type Configure struct { - Addr string - Root string - HttpAuth string - Cert string - Key string - Cors bool - Theme string - XProxy bool - Upload bool + Addr string + Root string + HttpAuth string + Cert string + Key string + Cors bool + Theme string + XProxy bool + Upload bool + PlistProxy *url.URL } var gcfg = Configure{} @@ -35,6 +37,7 @@ func parseFlags() { kingpin.Flag("theme", "web theme, one of ").Default("black").StringVar(&gcfg.Theme) kingpin.Flag("xproxy", "Used when behide proxy like nginx").BoolVar(&gcfg.XProxy) kingpin.Flag("upload", "Enable upload support").BoolVar(&gcfg.Upload) + kingpin.Flag("plistproxy", "IPA Plist file proxy, https needed").Short('p').URLVar(&gcfg.PlistProxy) kingpin.Parse() } @@ -45,6 +48,7 @@ func main() { ss := NewHTTPStaticServer("./") ss.Theme = gcfg.Theme + log.Println(gcfg.PlistProxy) if gcfg.Upload { ss.EnableUpload() }