Beispiel #1
0
// InConfigDir returns the path to the given filename inside of the configdir.
func InConfigDir(filename string) (string, error) {
	cdir := *configdir

	if cdir == "" {
		cdir = appdir.General("Lantern")
	}

	log.Debugf("Placing configuration in %v", cdir)
	if _, err := os.Stat(cdir); err != nil {
		if os.IsNotExist(err) {
			// Create config dir
			if err := os.MkdirAll(cdir, 0750); err != nil {
				return "", fmt.Errorf("Unable to create configdir at %s: %s", cdir, err)
			}
		}
	}

	return filepath.Join(cdir, filename), nil
}
Beispiel #2
0
	"github.com/getlantern/appdir"
	"github.com/getlantern/launcher"
	"github.com/getlantern/yaml"

	"github.com/getlantern/flashlight/ui"
)

const (
	messageType = `Settings`
)

var (
	service    *ui.Service
	settings   *Settings
	httpClient *http.Client
	path       = filepath.Join(appdir.General("Lantern"), "settings.yaml")
	once       = &sync.Once{}
)

// Settings is a struct of all settings unique to this particular Lantern instance.
type Settings struct {
	Version      string
	BuildDate    string
	RevisionDate string
	AutoReport   bool
	AutoLaunch   bool
	ProxyAll     bool
	SystemProxy  bool

	sync.RWMutex
}
Beispiel #3
0
	"github.com/getlantern/appdir"
	"github.com/getlantern/golog"
	"github.com/getlantern/yaml"
)

var (
	log  = golog.LoggerFor("flashlight.packaged")
	name = ".packaged-lantern.yaml"

	// This is the local copy of our embedded configuration file. This is necessary
	// to ensure we remember the embedded configuration across auto-updated
	// binaries. We write to the local file system instead of to the package
	// itself (app bundle on OSX, install directory on Windows) because
	// we're not always sure we can write to that directory.
	local = appdir.General("Lantern") + "/" + name
)

// PackagedSettings provided access to configuration embedded in the package.
type PackagedSettings struct {
	StartupUrl string
}

// ReadSettings reads packaged settings from pre-determined paths
// on the various OSes.
func ReadSettings() (string, *PackagedSettings, error) {
	yamlPath, err := packagedSettingsPath()
	if err != nil {
		return "", &PackagedSettings{}, err
	}