Documentation ¶
Index ¶
- func CheckVisibility(verbose bool) (map[string]bool, error)
- func CheckVisibilityIPPort(ip, port string, verbose bool) (bool, error)
- func GetAllIP() ([]string, error)
- func GetOutboundIP() (string, error)
- func PreferredLocalURL(verbose bool) (*url.URL, map[string]bool, error)
- func StartLocalServer(dir, ip, port string, verbose bool) (string, func(), error)
- type Server
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckVisibility ¶
CheckVisibility checks if api server could reach this client machine for each newtwork interface.
func CheckVisibilityIPPort ¶
CheckVisibilityIPPort checks if starting a local server over the given ip and port could be visible by the api server.
func GetOutboundIP ¶
GetOutboundIP gets the preferred outbound ip of this machine.
func PreferredLocalURL ¶
PreferredLocalURL returns visible url in following preference: non-localhost > localhost url.
Types ¶
type Server ¶
Server represents a local web server. Format of `Address` is `ip:port`, or `ip:` to get random port.
func (*Server) ServeStatic ¶
ServeStatic starts a static server serving the contents of the `directory` over `address`. It returns the http.Server and random port number with error.
Example ¶
s := Server{Directory: "/tmp"} staticServer, _, err := s.ServeStatic(true) if err != nil { panic(err) } time.Sleep(5 * time.Second) if err := staticServer.Shutdown(context.TODO()); err != nil { panic(err) } fmt.Println("Done")
Output: Done
Click to show internal directories.
Click to hide internal directories.