mirror of
https://github.com/xor-gate/go-socks5-ssh-proxy
synced 2026-03-23 06:16:35 +01:00
Initial working nesting in Python AppData installation
This commit is contained in:
24
vendor/github.com/emersion/go-autostart/.gitignore
generated
vendored
Normal file
24
vendor/github.com/emersion/go-autostart/.gitignore
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
21
vendor/github.com/emersion/go-autostart/LICENSE
generated
vendored
Normal file
21
vendor/github.com/emersion/go-autostart/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 ProtonMail
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
51
vendor/github.com/emersion/go-autostart/README.md
generated
vendored
Normal file
51
vendor/github.com/emersion/go-autostart/README.md
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
# go-autostart
|
||||
|
||||
[](https://godoc.org/github.com/emersion/go-autostart)
|
||||
|
||||
A Go library to run a command after login.
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"github.com/emersion/go-autostart"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := &autostart.App{
|
||||
Name: "test",
|
||||
DisplayName: "Just a Test App",
|
||||
Exec: []string{"sh", "-c", "echo autostart >> ~/autostart.txt"},
|
||||
}
|
||||
|
||||
if app.IsEnabled() {
|
||||
log.Println("App is already enabled, removing it...")
|
||||
|
||||
if err := app.Disable(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
log.Println("Enabling app...")
|
||||
|
||||
if err := app.Enable(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("Done!")
|
||||
}
|
||||
```
|
||||
|
||||
## Behavior
|
||||
|
||||
* On Linux and BSD, it creates a `.desktop` file in `$XDG_CONFIG_HOME/autostart`
|
||||
(i.e. `$HOME/.config/autostart`). See http://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login
|
||||
* On macOS, it creates a `launchd` job. See http://blog.gordn.org/2015/03/implementing-run-on-login-for-your-node.html
|
||||
* On Windows, it creates a link to the program in `%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup`
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
13
vendor/github.com/emersion/go-autostart/autostart.go
generated
vendored
Normal file
13
vendor/github.com/emersion/go-autostart/autostart.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
package autostart
|
||||
|
||||
// An application that will be started when the user logs in.
|
||||
type App struct {
|
||||
// Unique identifier for the app.
|
||||
Name string
|
||||
// The command to execute, followed by its arguments.
|
||||
Exec []string
|
||||
// The app name.
|
||||
DisplayName string
|
||||
// The app icon.
|
||||
Icon string
|
||||
}
|
||||
68
vendor/github.com/emersion/go-autostart/autostart_darwin.go
generated
vendored
Normal file
68
vendor/github.com/emersion/go-autostart/autostart_darwin.go
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
package autostart
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const jobTemplate = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>{{.Name}}</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
{{range .Exec -}}
|
||||
<string>{{.}}</string>
|
||||
{{end}}
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>AbandonProcessGroup</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>`
|
||||
|
||||
var launchDir string
|
||||
|
||||
func init() {
|
||||
launchDir = filepath.Join(os.Getenv("HOME"), "Library", "LaunchAgents")
|
||||
}
|
||||
|
||||
func (a *App) path() string {
|
||||
return filepath.Join(launchDir, a.Name+".plist")
|
||||
}
|
||||
|
||||
// IsEnabled Check is app enabled startup.
|
||||
func (a *App) IsEnabled() bool {
|
||||
_, err := os.Stat(a.path())
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// Enable this app on startup.
|
||||
func (a *App) Enable() error {
|
||||
t := template.Must(template.New("job").Parse(jobTemplate))
|
||||
|
||||
if err := os.MkdirAll(launchDir, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := os.Create(a.path())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
if err := t.Execute(f, a); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Disable this app on startup.
|
||||
func (a *App) Disable() error {
|
||||
|
||||
return os.Remove(a.path())
|
||||
}
|
||||
51
vendor/github.com/emersion/go-autostart/autostart_windows.c
generated
vendored
Normal file
51
vendor/github.com/emersion/go-autostart/autostart_windows.c
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <objbase.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
uint64_t CreateShortcut(char *shortcutA, char *path, char *args) {
|
||||
IShellLink* pISL;
|
||||
IPersistFile* pIPF;
|
||||
HRESULT hr;
|
||||
|
||||
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
|
||||
// Shortcut filename: convert ANSI to unicode
|
||||
WORD shortcutW[MAX_PATH];
|
||||
int nChar = MultiByteToWideChar(CP_ACP, 0, shortcutA, -1, shortcutW, MAX_PATH);
|
||||
|
||||
hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&pISL);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
return hr+0x01000000;
|
||||
}
|
||||
|
||||
// See https://msdn.microsoft.com/en-us/library/windows/desktop/bb774950(v=vs.85).aspx
|
||||
hr = pISL->lpVtbl->SetPath(pISL, path);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
return hr+0x02000000;
|
||||
}
|
||||
|
||||
hr = pISL->lpVtbl->SetArguments(pISL, args);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
return hr+0x03000000;
|
||||
}
|
||||
|
||||
// Save the shortcut
|
||||
hr = pISL->lpVtbl->QueryInterface(pISL, &IID_IPersistFile, (void**)&pIPF);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
return hr+0x04000000;
|
||||
}
|
||||
|
||||
hr = pIPF->lpVtbl->Save(pIPF, shortcutW, FALSE);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
return hr+0x05000000;
|
||||
}
|
||||
|
||||
pIPF->lpVtbl->Release(pIPF);
|
||||
pISL->lpVtbl->Release(pISL);
|
||||
|
||||
return 0x0;
|
||||
}
|
||||
52
vendor/github.com/emersion/go-autostart/autostart_windows.go
generated
vendored
Normal file
52
vendor/github.com/emersion/go-autostart/autostart_windows.go
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
package autostart
|
||||
|
||||
// #cgo LDFLAGS: -lole32 -luuid
|
||||
/*
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <stdint.h>
|
||||
#include <windows.h>
|
||||
|
||||
uint64_t CreateShortcut(char *shortcutA, char *path, char *args);
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var startupDir string
|
||||
|
||||
func init() {
|
||||
startupDir = filepath.Join(os.Getenv("USERPROFILE"), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", "Startup")
|
||||
}
|
||||
|
||||
func (a *App) path() string {
|
||||
return filepath.Join(startupDir, a.Name+".lnk")
|
||||
}
|
||||
|
||||
func (a *App) IsEnabled() bool {
|
||||
_, err := os.Stat(a.path())
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func (a *App) Enable() error {
|
||||
path := a.Exec[0]
|
||||
args := strings.Join(a.Exec[1:], " ")
|
||||
|
||||
if err := os.MkdirAll(startupDir, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
res := C.CreateShortcut(C.CString(a.path()), C.CString(path), C.CString(args))
|
||||
if res != 0 {
|
||||
return errors.New(fmt.Sprintf("autostart: cannot create shortcut '%s' error code: 0x%.8x", a.path(), res))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) Disable() error {
|
||||
return os.Remove(a.path())
|
||||
}
|
||||
69
vendor/github.com/emersion/go-autostart/autostart_xdg.go
generated
vendored
Normal file
69
vendor/github.com/emersion/go-autostart/autostart_xdg.go
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
// +build !windows,!darwin
|
||||
|
||||
package autostart
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const desktopTemplate = `[Desktop Entry]
|
||||
Type=Application
|
||||
Name={{.DisplayName}}
|
||||
Exec={{.Exec}}
|
||||
{{- if .Icon}}
|
||||
Icon={{.Icon}}{{end}}
|
||||
X-GNOME-Autostart-enabled=true
|
||||
`
|
||||
|
||||
var autostartDir string
|
||||
|
||||
func init() {
|
||||
if os.Getenv("XDG_CONFIG_HOME") != "" {
|
||||
autostartDir = os.Getenv("XDG_CONFIG_HOME")
|
||||
} else {
|
||||
autostartDir = filepath.Join(os.Getenv("HOME"), ".config")
|
||||
}
|
||||
autostartDir = filepath.Join(autostartDir, "autostart")
|
||||
}
|
||||
|
||||
func (a *App) path() string {
|
||||
return filepath.Join(autostartDir, a.Name+".desktop")
|
||||
}
|
||||
|
||||
// Check if the app is enabled on startup.
|
||||
func (a *App) IsEnabled() bool {
|
||||
_, err := os.Stat(a.path())
|
||||
return err == nil
|
||||
}
|
||||
|
||||
type app struct {
|
||||
*App
|
||||
}
|
||||
|
||||
// Override App.Exec to return a string.
|
||||
func (a *app) Exec() string {
|
||||
return quote(a.App.Exec)
|
||||
}
|
||||
|
||||
// Enable this app on startup.
|
||||
func (a *App) Enable() error {
|
||||
t := template.Must(template.New("desktop").Parse(desktopTemplate))
|
||||
|
||||
if err := os.MkdirAll(autostartDir, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := os.Create(a.path())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return t.Execute(f, &app{a})
|
||||
}
|
||||
|
||||
// Disable this app on startup.
|
||||
func (a *App) Disable() error {
|
||||
return os.Remove(a.path())
|
||||
}
|
||||
16
vendor/github.com/emersion/go-autostart/quote.go
generated
vendored
Normal file
16
vendor/github.com/emersion/go-autostart/quote.go
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// +build !darwin
|
||||
|
||||
package autostart
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func quote(args []string) string {
|
||||
for i, v := range args {
|
||||
args[i] = strconv.Quote(v)
|
||||
}
|
||||
|
||||
return strings.Join(args, " ")
|
||||
}
|
||||
Reference in New Issue
Block a user