Documentation
¶
Index ¶
- Variables
- func OnDNSConfigChanged(ifname string)
- func RequestVPN(service IPNService)
- func SendLog(logstr []byte)
- func ServiceDisconnect(service IPNService)
- type App
- func (app *App) CallLocalAPI(timeoutMillis int, method, endpoint string, body InputStream) (LocalAPIResponse, error)
- func (app *App) CallLocalAPIMultipart(timeoutMillis int, method, endpoint string, parts FileParts) (LocalAPIResponse, error)
- func (app *App) EditPrefs(prefs ipn.MaskedPrefs) (LocalAPIResponse, error)
- func (app *App) NotifyPolicyChanged()
- func (app *App) WatchNotifications(mask int, cb NotificationCallback) NotificationManager
- type AppContext
- type Application
- type FilePart
- type FileParts
- type IPNService
- type InputStream
- type LocalAPIResponse
- type NotificationCallback
- type NotificationManager
- type ParcelFileDescriptor
- type Response
- func (r *Response) Body() net.Conn
- func (r *Response) BodyBytes() ([]byte, error)
- func (r *Response) BodyInputStream() InputStream
- func (r *Response) Flush()
- func (r *Response) Header() http.Header
- func (r *Response) StatusCode() int
- func (r *Response) Write(data []byte) (int, error)
- func (r *Response) WriteHeader(statusCode int)
- type VPNFacade
- func (vf *VPNFacade) Close() error
- func (vf *VPNFacade) GetBaseConfig() (dns.OSConfig, error)
- func (vf *VPNFacade) ReconfigureVPN() error
- func (vf *VPNFacade) Set(rcfg *router.Config) error
- func (vf *VPNFacade) SetDNS(dcfg dns.OSConfig) error
- func (vf *VPNFacade) SupportsSplitDNS() bool
- func (vf *VPNFacade) Up() error
- func (vf *VPNFacade) UpdateMagicsockPort(_ uint16, _ string) error
- type VPNServiceBuilder
- type VpnService
Constants ¶
This section is empty.
Variables ¶
var ID = filepath.Base(os.Args[0])
Functions ¶
func OnDNSConfigChanged ¶
func OnDNSConfigChanged(ifname string)
ifname is the interface name retrieved from LinkProperties on network change. An empty string is used if there is no network available.
func RequestVPN ¶
func RequestVPN(service IPNService)
func ServiceDisconnect ¶
func ServiceDisconnect(service IPNService)
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) CallLocalAPI ¶
func (app *App) CallLocalAPI(timeoutMillis int, method, endpoint string, body InputStream) (LocalAPIResponse, error)
CallLocalAPI is the method for making localapi calls from Kotlin. It calls the given endpoint on the local API using the given HTTP method and optionally sending the given body. It returns a Response representing the result of the call and an error if the call could not be completed or the local API returned a status code in the 400 series or greater. Note - Response includes a response body available from the Body method, it is the caller's responsibility to close this.
func (*App) CallLocalAPIMultipart ¶
func (app *App) CallLocalAPIMultipart(timeoutMillis int, method, endpoint string, parts FileParts) (LocalAPIResponse, error)
CallLocalAPIMultipart is like CallLocalAPI, but instead of uploading a generic body, it uploads a multipart/form-encoded body consisting of the supplied parts.
func (*App) EditPrefs ¶
func (app *App) EditPrefs(prefs ipn.MaskedPrefs) (LocalAPIResponse, error)
func (*App) NotifyPolicyChanged ¶
func (app *App) NotifyPolicyChanged()
func (*App) WatchNotifications ¶
func (app *App) WatchNotifications(mask int, cb NotificationCallback) NotificationManager
type AppContext ¶
type AppContext interface { // Log logs the given tag and logLine Log(tag, logLine string) // EncryptToPref stores the given value to an encrypted preference at the // given key. EncryptToPref(key, value string) error // DecryptFromPref retrieves the given value from an encrypted preference // at the given key, or returns empty string if unset. DecryptFromPref(key string) (string, error) // GetOSVersion gets the Android version. GetOSVersion() (string, error) // GetModelName gets the Android device's model name. GetModelName() (string, error) // GetInstallSource gets information about how the app was installed or updated. GetInstallSource() string // ShouldUseGoogleDNSFallback reports whether or not to use Google for DNS fallback. ShouldUseGoogleDNSFallback() bool // IsChromeOS reports whether we're on a ChromeOS device. IsChromeOS() (bool, error) // GetInterfacesAsString gets a string representation of all network // interfaces. GetInterfacesAsString() (string, error) // GetPlatformDNSConfig gets a string representation of the current DNS // configuration. GetPlatformDNSConfig() string // GetSyspolicyStringValue returns the current string value for the given system policy. GetSyspolicyStringValue(key string) (string, error) // GetSyspolicyBooleanValue returns whether the given system policy is enabled. GetSyspolicyBooleanValue(key string) (bool, error) // GetSyspolicyStringArrayValue returns the current string array value for the given system policy, // expressed as a JSON string. GetSyspolicyStringArrayJSONValue(key string) (string, error) }
AppContext provides a context within which the Application is running. This context is a hook into functionality that's implemented on the Java side.
type Application ¶
type Application interface { // CallLocalAPI provides a mechanism for calling Tailscale's HTTP localapi // without having to call over the network. CallLocalAPI(timeoutMillis int, method, endpoint string, body InputStream) (LocalAPIResponse, error) // CallLocalAPIMultipart is like CallLocalAPI, but instead of a single body, // it accepts multiple FileParts that get encoded as multipart/form-data. CallLocalAPIMultipart(timeoutMillis int, method, endpoint string, parts FileParts) (LocalAPIResponse, error) // NotifyPolicyChanged notifies the backend about a changed MDM policy, // so it can re-read it via the [syspolicyHandler]. NotifyPolicyChanged() // WatchNotifications provides a mechanism for subscribing to ipn.Notify // updates. The given NotificationCallback's OnNotify function is invoked // on every new ipn.Notify message. The returned NotificationManager // allows the watcher to stop watching notifications. WatchNotifications(mask int, cb NotificationCallback) NotificationManager }
Application encapsulates the running Tailscale Application. There is only a single instance of Application per Android application.
func Start ¶
func Start(dataDir, directFileRoot string, appCtx AppContext) Application
Start starts the application, storing state in the given dataDir and using the given appCtx.
type FilePart ¶
type FilePart struct { ContentLength int64 Filename string Body InputStream ContentType string // optional MIME content type }
FilePart is a multipart file that can be submitted via CallLocalAPIMultiPart.
type IPNService ¶
type IPNService interface { // ID returns the unique ID of this instance of the IPNService. Every time // we start a new IPN service, it should have a new ID. ID() string // Protect protects socket identified by the given file descriptor from // being captured by the VPN. The return value indicates whether or not the // socket was successfully protected. Protect(fd int32) bool // NewBuilder creates a new VPNServiceBuilder in preparation for starting // the Android VPN. NewBuilder() VPNServiceBuilder Close() DisconnectVPN() UpdateVpnStatus(bool) }
IPNService corresponds to our IPNService in Java.
type InputStream ¶
InputStream provides an adapter between Java's InputStream and Go's io.Reader.
type LocalAPIResponse ¶
type LocalAPIResponse interface { StatusCode() int BodyBytes() ([]byte, error) BodyInputStream() InputStream }
LocalAPIResponse is a response to a localapi call, analogous to an http.Response.
type NotificationCallback ¶
NotificationCallback is callback for receiving ipn.Notify messages.
type NotificationManager ¶
type NotificationManager interface {
Stop()
}
NotificationManager provides a mechanism for a notification watcher to stop watching notifications.
type ParcelFileDescriptor ¶
ParcelFileDescriptor corresponds to Android's ParcelFileDescriptor.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response represents the result of processing an localAPI request. On completion, the response body can be read out of the bodyWriter.
func (*Response) BodyInputStream ¶
func (r *Response) BodyInputStream() InputStream
func (*Response) StatusCode ¶
func (*Response) Write ¶
Write writes the data to the response body which an then be read out as a json object.
func (*Response) WriteHeader ¶
type VPNFacade ¶
type VPNFacade struct { SetBoth func(rcfg *router.Config, dcfg *dns.OSConfig) error // GetBaseConfigFunc optionally specifies a function to return the current DNS // config in response to GetBaseConfig. // // If nil, reading the current config isn't supported and GetBaseConfig() // will return ErrGetBaseConfigNotSupported. GetBaseConfigFunc func() (dns.OSConfig, error) // InitialMTU is the MTU the tun should be initialized with. // Zero means don't change the MTU from the default. This MTU // is applied only once, shortly after the TUN is created, and // ignored thereaftef. InitialMTU uint32 // contains filtered or unexported fields }
VPNFacade is an implementation of both wgengine.Router and dns.OSConfigurator. When ReconfigureVPN is called by the backend, SetBoth gets called.
func (*VPNFacade) GetBaseConfig ¶
Implements dns.OSConfigurator.
func (*VPNFacade) ReconfigureVPN ¶
ReconfigureVPN is the method value passed to wgengine.Config.ReconfigureVPN.
func (*VPNFacade) SupportsSplitDNS ¶
Implements dns.OSConfigurator.
type VPNServiceBuilder ¶
type VPNServiceBuilder interface { SetMTU(int32) error AddDNSServer(string) error AddSearchDomain(string) error AddRoute(string, int32) error ExcludeRoute(string, int32) error AddAddress(string, int32) error Establish() (ParcelFileDescriptor, error) }
VPNServiceBuilder corresponds to Android's VpnService.Builder.
type VpnService ¶
type VpnService struct {
// contains filtered or unexported fields
}
VpnService contains the IPNService class from Android, the file descriptor, and whether the descriptor has been detached.