Esempio n. 1
0
func Configure(provider Provider) error {

	log.Debugf("Configuring Lantern version: %s", lantern.GetVersion())

	settingsDir := provider.SettingsDir()
	log.Debugf("settings directory is %s", settingsDir)

	appdir.AndroidDir = settingsDir
	settings.SetAndroidPath(settingsDir)
	appSettings = settings.Load(lantern.GetVersion(), lantern.GetRevisionDate(), "")

	return nil
}
Esempio n. 2
0
// Start creates a new client at the given address.
func Start(provider Provider) error {

	go func() {

		log.Debugf("About to configure Lantern")

		if provider.VpnMode() {
			dnsServer := provider.GetDnsServer()
			protected.Configure(provider, dnsServer, true)
		}

		androidProps := map[string]string{
			"androidDevice":     provider.Device(),
			"androidModel":      provider.Model(),
			"androidSdkVersion": provider.Version(),
		}
		logging.ConfigureAndroid(androidProps)

		cfgFn := func(cfg *config.Config) {

		}

		l, err := lantern.Start(false, true, false,
			true, cfgFn)

		if err != nil {
			log.Fatalf("Could not start Lantern")
		}

		if provider.VpnMode() {
			i, err = interceptor.Do(l.Client, appSettings.SocksAddr, appSettings.HttpAddr, provider.Notice)
			if err != nil {
				log.Errorf("Error starting interceptor: %v", err)
			} else {
				lantern.AddExitFunc(func() {
					if i != nil {
						i.Stop()
					}
				})
			}
		}
		provider.AfterStart(lantern.GetVersion())
	}()
	return nil
}