mobile

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

Mobile API

This package is a mobile API for the dnsproxy.

We are using gomobile to build mobile bindings as it is explained in the documentation.

How to build

You will need go v1.11 or newer.

To build the Android library:

$ export ANDROID_HOME=PATH_TO_ANDROID_SDK
$ make clean
$ make android

To build the iOS library (please note that you need to execute it on macOS):

$ make clean
$ make ios

TODO

There is a known issue with gomobile not supporting go modules. Unfortunately, until this issue is resolved, we have to use a complicated make file

  • Android library build
  • iOS library build
  • Update the build script once go modules support is added to gomobile

Documentation

Overview

Package mobile contains a simple mobile API for github.com/AdguardTeam/dnsproxy

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLogger added in v0.9.14

func ConfigureLogger(verbose bool, w LogWriter)

ConfigureLogger function is called from mobile API to write dnsproxy log into mobile log You need to create object that implements LogWriter interface and set it as argument of this function

func TestUpstream added in v0.9.7

func TestUpstream(address string, bootstrap []string, timeout int) error

TestUpstream checks if upstream is valid and available If it is, no error is returned. Otherwise this method returns an error with an explanation. * address - see upstream.AddressToUpstream for examples * bootstrap - an optional bootstrap DNS * timeout - timeout in milliseconds

Types

type Config

type Config struct {
	ListenAddr   string // IP address to listen to
	ListenPort   int    // Port to listen to
	BootstrapDNS string // A list of bootstrap DNS (i.e. 8.8.8.8:53 each on a new line)
	Fallbacks    string // A list of fallback resolvers that will be used if the main one is not available (i.e. 1.1.1.1:53 each on a new line)
	Upstreams    string // A list of upstream resolvers (each on a new line)
	Timeout      int    // Default timeout for all resolvers (milliseconds)
}

Config is the DNS proxy configuration which uses only the subset of types that is supported by gomobile In Java API this structure becomes an object that needs to be configured and setted as field of DNSProxy

type DNSProxy

type DNSProxy struct {
	Config *Config // Proxy configuration

	sync.RWMutex
	// contains filtered or unexported fields
}

DNSProxy represents a proxy with it's configuration

func (*DNSProxy) Addr

func (d *DNSProxy) Addr() string

Addr gets the address proxy is currently listening to

func (*DNSProxy) Start

func (d *DNSProxy) Start() error

Start starts the DNS proxy

func (*DNSProxy) Stop

func (d *DNSProxy) Stop() error

Stop stops the DNS proxy

type DNSStamp added in v0.9.7

type DNSStamp struct {
	Proto        int    // Protocol (0x00 for plain, 0x01 for DNSCrypt, 0x02 for DOH, 0x03 for DOT
	ServerAddr   string // Server address
	ProviderName string // Provider name
	Path         string // Path (for DOH)
}

DNSStamp is mobile-friendly DNS stamp structure

func ParseDNSStamp added in v0.9.7

func ParseDNSStamp(stampStr string) (*DNSStamp, error)

ParseDNSStamp parses a DNS stamp string and returns a stamp instance or an error

type LogWriter added in v0.9.14

type LogWriter interface {
	Write(s string)
}

LogWriter interface should be implemented inside project that will use dnsproxy mobile API to write dnsproxy log into mobile log

type LogWriterAdapter added in v0.9.14

type LogWriterAdapter struct {
	// contains filtered or unexported fields
}

LogWriterAdapter between go log and LogWriter

func (*LogWriterAdapter) Write added in v0.9.14

func (w *LogWriterAdapter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL