This commit is contained in:
parent
365e0feddc
commit
ce19d6a62c
24 changed files with 212 additions and 96 deletions
|
@ -1,7 +1,7 @@
|
||||||
If:
|
If:
|
||||||
PathMatch: '.*\.(c|h)'
|
PathMatch: '.*\.(c|h)'
|
||||||
CompileFlags:
|
CompileFlags:
|
||||||
Add: [ -std=c99 ]
|
Add: [ -xc, -std=c99 ]
|
||||||
|
|
||||||
---
|
---
|
||||||
If:
|
If:
|
||||||
|
|
41
.config/nvim/.luarc.json
Normal file
41
.config/nvim/.luarc.json
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"workspace.library": [
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/neodev.nvim/types/stable",
|
||||||
|
"/usr/share/nvim/runtime/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-surround/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-tree.lua/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/cmp-nvim-lsp/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/cmp-buffer/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/lspkind.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/lualine.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-web-devicons/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-treesitter-context/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-treesitter/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/indent-blankline.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-notify/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-colorizer.lua/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/mason.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/lazy.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/LuaSnip/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-lastplace/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/telescope.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/Navigator.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/trouble.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/bufferline.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/Comment.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-lspconfig/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/neodev.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/onedark.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/plenary.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/fidget.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-autopairs/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/todo-comments.nvim/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/nvim-cmp/lua",
|
||||||
|
"/home/wzray/.local/share/nvim/lazy/telescope-emoji.nvim/lua",
|
||||||
|
"/usr/share/nvim/runtime",
|
||||||
|
"/home/wzray/.dotfiles/.config/nvim/lua",
|
||||||
|
"${3rd}/luv/library"
|
||||||
|
]
|
||||||
|
}
|
|
@ -33,6 +33,8 @@
|
||||||
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||||
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
|
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
|
||||||
"trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" },
|
"trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" },
|
||||||
|
"vim-bbcode": { "branch": "master", "commit": "6fb28c6deae5844ee2bf0b97ef2fea04bd3d4eac" },
|
||||||
|
"vim-caddyfile": { "branch": "master", "commit": "24fe0720551883e407cb70ae1d7c03f162d1d5a0" },
|
||||||
"vim-fugitive": { "branch": "master", "commit": "320b18fba2a4f2fe3c8225c778c687e0d2620384" },
|
"vim-fugitive": { "branch": "master", "commit": "320b18fba2a4f2fe3c8225c778c687e0d2620384" },
|
||||||
"vim-peekaboo": { "branch": "master", "commit": "cc4469c204099c73dd7534531fa8ba271f704831" },
|
"vim-peekaboo": { "branch": "master", "commit": "cc4469c204099c73dd7534531fa8ba271f704831" },
|
||||||
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }
|
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }
|
||||||
|
|
|
@ -9,7 +9,7 @@ vim.wo.relativenumber = true
|
||||||
vim.o.mouse = 'a'
|
vim.o.mouse = 'a'
|
||||||
|
|
||||||
-- Indentation
|
-- Indentation
|
||||||
vim.o.tabstop = 8
|
vim.o.tabstop = 4
|
||||||
vim.o.expandtab = true
|
vim.o.expandtab = true
|
||||||
vim.o.shiftwidth = 4
|
vim.o.shiftwidth = 4
|
||||||
vim.o.autoindent = true
|
vim.o.autoindent = true
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
local servers = {
|
local servers = {
|
||||||
bashls = {},
|
bashls = {},
|
||||||
|
cmake = {},
|
||||||
clangd = {},
|
clangd = {},
|
||||||
eslint = {},
|
eslint = {},
|
||||||
gopls = {},
|
gopls = {},
|
||||||
|
@ -8,9 +9,12 @@ local servers = {
|
||||||
kotlin_language_server = {},
|
kotlin_language_server = {},
|
||||||
lua_ls = require('lsp.lua_ls'),
|
lua_ls = require('lsp.lua_ls'),
|
||||||
pyright = {},
|
pyright = {},
|
||||||
|
ruby_lsp = {},
|
||||||
rust_analyzer = {},
|
rust_analyzer = {},
|
||||||
ts_ls = {},
|
ts_ls = {},
|
||||||
ruby_lsp = {},
|
yamlls = require('lsp.yamlls'),
|
||||||
|
jsonls = {},
|
||||||
|
svls = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.lsp.set_log_level("debug")
|
vim.lsp.set_log_level("debug")
|
||||||
|
@ -44,22 +48,6 @@ end
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
local lspconfig = require('lspconfig')
|
local lspconfig = require('lspconfig')
|
||||||
|
|
||||||
for server_name, config in pairs(servers) do
|
|
||||||
lspconfig[server_name].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
[server_name] = config ~= {} and {
|
|
||||||
settings = {
|
|
||||||
[server_name] = {
|
|
||||||
config
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} or {}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
for server_name, config in pairs(servers) do
|
for server_name, config in pairs(servers) do
|
||||||
lspconfig[server_name].setup(vim.tbl_deep_extend('keep', {
|
lspconfig[server_name].setup(vim.tbl_deep_extend('keep', {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
return {
|
return {
|
||||||
root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'mvnw'}, { upward = true })[1]),
|
settings = {
|
||||||
|
root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'mvnw'}, { upward = true })[1]),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
return {
|
return {
|
||||||
Lua = {
|
settings = {
|
||||||
workspace = {
|
Lua = {
|
||||||
checkThirdParty = true,
|
workspace = {
|
||||||
library = {
|
checkThirdParty = true,
|
||||||
vim.env.VIMRUNTIME
|
library = {
|
||||||
}
|
vim.env.VIMRUNTIME
|
||||||
|
}
|
||||||
|
},
|
||||||
|
telemetry = { enable = false },
|
||||||
},
|
},
|
||||||
telemetry = { enable = false },
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
9
.config/nvim/lua/lsp/yamlls.lua
Normal file
9
.config/nvim/lua/lsp/yamlls.lua
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
redhat = {
|
||||||
|
telemetry = {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
return {
|
return {
|
||||||
|
'isobit/vim-caddyfile',
|
||||||
'rcarriga/nvim-notify',
|
'rcarriga/nvim-notify',
|
||||||
'stefandtw/quickfix-reflector.vim',
|
'stefandtw/quickfix-reflector.vim',
|
||||||
'tpope/vim-fugitive',
|
'tpope/vim-fugitive',
|
||||||
|
'junegunn/vim-peekaboo',
|
||||||
'tpope/vim-sleuth',
|
'tpope/vim-sleuth',
|
||||||
'vim-scripts/iptables',
|
'vim-scripts/iptables',
|
||||||
{ 'akinsho/bufferline.nvim', opts = {}, dependencies = { 'navarasu/onedark.nvim' } },
|
{ 'akinsho/bufferline.nvim', opts = {}, dependencies = { 'navarasu/onedark.nvim' } },
|
||||||
|
@ -12,4 +14,5 @@ return {
|
||||||
{ 'norcalli/nvim-colorizer.lua', opts={ '*' }, dependencies = { 'navarasu/onedark.nvim' } },
|
{ 'norcalli/nvim-colorizer.lua', opts={ '*' }, dependencies = { 'navarasu/onedark.nvim' } },
|
||||||
-- { 'wakatime/vim-wakatime', event = 'VeryLazy' },
|
-- { 'wakatime/vim-wakatime', event = 'VeryLazy' },
|
||||||
{ 'williamboman/mason.nvim', opts = {} },
|
{ 'williamboman/mason.nvim', opts = {} },
|
||||||
|
'Winseven4lyf/vim-bbcode',
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
return {
|
|
||||||
'junegunn/vim-peekaboo',
|
|
||||||
config = function ()
|
|
||||||
vim.g.peekaboo_window = 'enew'
|
|
||||||
end
|
|
||||||
}
|
|
|
@ -7,12 +7,16 @@ return {
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
config = function()
|
config = function()
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
-- - @diagnostic disable-next-line: missing-fields
|
--- @diagnostic disable-next-line: missing-fields
|
||||||
require('nvim-treesitter.configs').setup({
|
require('nvim-treesitter.configs').setup({
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
require('treesitter-context').setup {
|
||||||
|
max_lines = 6
|
||||||
|
}
|
||||||
end, 0)
|
end, 0)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
30
.config/nvim/lua/plugins/ufo.lua
Normal file
30
.config/nvim/lua/plugins/ufo.lua
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
return {
|
||||||
|
-- 'kevinhwang91/nvim-ufo',
|
||||||
|
-- dependencies = {
|
||||||
|
-- 'kevinhwang91/promise-async'
|
||||||
|
-- },
|
||||||
|
-- config = function()
|
||||||
|
-- vim.defer_fn(function()
|
||||||
|
-- vim.o.foldcolumn = '0'
|
||||||
|
-- vim.o.foldlevel = 99
|
||||||
|
-- vim.o.foldlevelstart = 99
|
||||||
|
-- vim.o.foldenable = true
|
||||||
|
--
|
||||||
|
-- vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
|
||||||
|
-- vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
|
||||||
|
--
|
||||||
|
-- local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
-- capabilities.textDocument.foldingRange = {
|
||||||
|
-- dynamicRegistration = false,
|
||||||
|
-- lineFoldingOnly = true
|
||||||
|
-- }
|
||||||
|
-- local language_servers = vim.lsp.get_clients()
|
||||||
|
-- for _, ls in ipairs(language_servers) do
|
||||||
|
-- require('lspconfig')[ls].setup({
|
||||||
|
-- capabilities = capabilities
|
||||||
|
-- })
|
||||||
|
-- end
|
||||||
|
-- require('ufo').setup()
|
||||||
|
-- end, 0)
|
||||||
|
-- end
|
||||||
|
}
|
|
@ -1,11 +1,12 @@
|
||||||
[ -f "~/.config/.fix-tty" ] || return
|
[ -f "$HOME/.config/.fix-tty" ] || return
|
||||||
|
|
||||||
process_id="$$"
|
process_id="$$"
|
||||||
(
|
(
|
||||||
if [ "$(inxi -aG | grep -c 'Monitor')" -eq 1 ]; then
|
if [ "$(inxi -aG | grep -c 'Monitor')" = "1" ]; then
|
||||||
setfont Uni3-Terminus32x16.psf.gz
|
setfont ter-v32n
|
||||||
stty -F /proc/$process_id/fd/0 rows 65 cols 195
|
stty -F /proc/$process_id/fd/0 rows 65 cols 195
|
||||||
else
|
else
|
||||||
setfont Uni3-Terminus16.psf.gz
|
setfont ter-v16n
|
||||||
stty -F /proc/$process_id/fd/0 rows 90 cols 320
|
stty -F /proc/$process_id/fd/0 rows 90 cols 320
|
||||||
fi >/dev/null 2>&1 &
|
fi >/dev/null 2>&1 &
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,6 +32,7 @@ bindkey "^[[1;3C" forward-word
|
||||||
bindkey "^[[1;5C" forward-word
|
bindkey "^[[1;5C" forward-word
|
||||||
bindkey "^[[1;3D" backward-word
|
bindkey "^[[1;3D" backward-word
|
||||||
bindkey "^[[1;5D" backward-word
|
bindkey "^[[1;5D" backward-word
|
||||||
|
bindkey "^[[3~" delete-char
|
||||||
|
|
||||||
bindkey "^[n" backward-word
|
bindkey "^[n" backward-word
|
||||||
bindkey "^[m" forward-word
|
bindkey "^[m" forward-word
|
||||||
|
@ -88,10 +89,13 @@ alias d="diff --color -u "
|
||||||
alias rgf="rg --files | rg "
|
alias rgf="rg --files | rg "
|
||||||
alias 7z="7zz" # for whatever reason 7z provides 7zz binary in debian
|
alias 7z="7zz" # for whatever reason 7z provides 7zz binary in debian
|
||||||
alias wt="watch --color -d -cn 0.1 "
|
alias wt="watch --color -d -cn 0.1 "
|
||||||
alias cal="ncal -b"
|
alias .e="set -a && source .env && set +a"
|
||||||
alias .e="source .env"
|
|
||||||
alias vimu="vim -u /dev/null"
|
alias vimu="vim -u /dev/null"
|
||||||
alias reswap="sudo swapoff /swapfile && sudo swapon /swapfile"
|
alias reswap="sudo bash -c 'echo Working...; swapoff /swapfile && sudo swapon /swapfile'"
|
||||||
|
alias make="make -j$(nproc)"
|
||||||
|
alias py="python3"
|
||||||
|
alias neofetch="fastfetch"
|
||||||
|
alias open="xdg-open"
|
||||||
|
|
||||||
# function aliases
|
# function aliases
|
||||||
bl() { brightnessctl set "$1"% > /dev/null; }
|
bl() { brightnessctl set "$1"% > /dev/null; }
|
||||||
|
@ -107,12 +111,15 @@ compdef '_files -g "*.md"' md
|
||||||
# git aliases
|
# git aliases
|
||||||
gl() { git log --decorate "$@" | bat }; compdef '_git; _git-log' gl
|
gl() { git log --decorate "$@" | bat }; compdef '_git; _git-log' gl
|
||||||
gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}"}; compdef '_git; _git-push' gus
|
gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}"}; compdef '_git; _git-push' gus
|
||||||
|
gpo() { git push --set-upstream origin ${1:-$(git rev-parse --abbrev-ref HEAD)}}
|
||||||
alias ga="git add"
|
alias ga="git add"
|
||||||
alias gb="git branch"
|
alias gb="git branch"
|
||||||
alias gc="git commit"
|
alias gc="git commit"
|
||||||
alias gca="git commit --amend --no-edit"
|
alias gca="git commit --allow-empty-message --amend --no-edit"
|
||||||
alias gck="git checkout"
|
alias gck="git checkout"
|
||||||
alias gcl="git clone"
|
alias gcl="git clone"
|
||||||
|
alias gcls="git clone --depth=1"
|
||||||
|
alias gcm="git commit --allow-empty-message -m ''"
|
||||||
alias gcn="git clean"
|
alias gcn="git clean"
|
||||||
alias gcp="git cherry-pick"
|
alias gcp="git cherry-pick"
|
||||||
alias gd="git diff"
|
alias gd="git diff"
|
||||||
|
@ -122,7 +129,6 @@ alias gi="git init"
|
||||||
alias gla="gl --all"
|
alias gla="gl --all"
|
||||||
alias gm="git merge"
|
alias gm="git merge"
|
||||||
alias gp="git push"
|
alias gp="git push"
|
||||||
alias gpo="git push origin"
|
|
||||||
alias gpu="git pull"
|
alias gpu="git pull"
|
||||||
alias gr="git restore"
|
alias gr="git restore"
|
||||||
alias grj="git rebase"
|
alias grj="git rebase"
|
||||||
|
@ -134,9 +140,10 @@ alias grt="git reset"
|
||||||
alias gs="git status"
|
alias gs="git status"
|
||||||
alias gsc="git switch -c"
|
alias gsc="git switch -c"
|
||||||
alias gsh="git show"
|
alias gsh="git show"
|
||||||
alias gsp="git stash pop"
|
|
||||||
alias gsj="git stash"
|
alias gsj="git stash"
|
||||||
|
alias gsp="git stash pop"
|
||||||
alias gt="git tag"
|
alias gt="git tag"
|
||||||
|
alias gus="git fetch --unshallow"
|
||||||
|
|
||||||
# docker aliases
|
# docker aliases
|
||||||
alias dc="docker compose"
|
alias dc="docker compose"
|
||||||
|
|
BIN
.fonts/EngraversGothic-Bold.ttf
Normal file
BIN
.fonts/EngraversGothic-Bold.ttf
Normal file
Binary file not shown.
|
@ -11,6 +11,6 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh -p 8022 u0_a343@"$phone_ip" 'su -c setprop service.adb.tcp.port 5555 && su -c stop adbd && su -c start adbd'
|
ssh -p 8022 u0_a230@"$phone_ip" 'su -c setprop service.adb.tcp.port 5555 && su -c stop adbd && su -c start adbd'
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
adb connect "$phone_ip"
|
adb connect "$phone_ip"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
url="$(git remote get-url "${1:-origin}")"
|
url="$(git remote get-url "${1:-origin}")"
|
||||||
|
|
||||||
if [[ "$url" =~ ^https?:\/\/ ]]; then
|
if [[ "$url" =~ ^https?:\/\/ ]]; then
|
||||||
echo "$url"
|
xdg-open "$url"
|
||||||
elif [[ "$url" =~ ^[a-zA-Z0-9_-]+@([a-zA-Z0-9_.-]+):(.*) ]]; then
|
elif [[ "$url" =~ ^[a-zA-Z0-9_-]+@([a-zA-Z0-9_.-]+):(.*) ]]; then
|
||||||
url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
|
url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
|
||||||
url="${url%.git}"
|
url="${url%.git}"
|
||||||
|
|
|
@ -46,8 +46,6 @@ def run_until_successful(fn: Callable[..., T], *args, **kwargs) -> T:
|
||||||
return fn(*args, **kwargs)
|
return fn(*args, **kwargs)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
|
||||||
break # no it's not >( # pyright: ignore
|
|
||||||
|
|
||||||
|
|
||||||
def send_message(chat_id: int, text: str, token: str):
|
def send_message(chat_id: int, text: str, token: str):
|
||||||
|
@ -180,14 +178,22 @@ class Api:
|
||||||
self._first_auth()
|
self._first_auth()
|
||||||
|
|
||||||
|
|
||||||
def get_status_list(self):
|
def _make_request(self, method: Literal["GET", "POST"], endpoint: str):
|
||||||
self._ensure_authorized()
|
self._ensure_authorized()
|
||||||
r = run_until_successful(self._session.get, 'https://my.itmo.ru/api/requests/my', timeout=2)
|
r = run_until_successful(self._session.request, method, f'https://my.itmo.ru/api/{endpoint}', timeout=2)
|
||||||
|
|
||||||
|
if r.status_code == 403:
|
||||||
|
self._first_auth() # do full reauth if 403 after self._ensure_authorized()
|
||||||
|
r = run_until_successful(self._session.request, method, f'https://my.itmo.ru/api/{endpoint}', timeout=2)
|
||||||
|
|
||||||
if r.status_code != 200 or r.json()['error_code'] != 0:
|
if r.status_code != 200 or r.json()['error_code'] != 0:
|
||||||
raise ApiException(r.status_code, r.text)
|
raise ApiException(r.status_code, r.text)
|
||||||
|
|
||||||
return [StatusObject.from_dict(obj) for obj in r.json()['result']]
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
|
def get_status_list(self):
|
||||||
|
return [StatusObject.from_dict(obj) for obj in self._make_request('GET', 'requests/my')['result']]
|
||||||
|
|
||||||
|
|
||||||
def to_dict(self) -> Any:
|
def to_dict(self) -> Any:
|
||||||
|
@ -305,13 +311,13 @@ def main():
|
||||||
print('\n'.join(map(format_status, message)))
|
print('\n'.join(map(format_status, message)))
|
||||||
file.write(' '.join(map(format_status, message)))
|
file.write(' '.join(map(format_status, message)))
|
||||||
|
|
||||||
# update_filter = LastUpdateFilter(ignore_now=True)
|
update_filter = LastUpdateFilter(ignore_now=True)
|
||||||
# for message in listen_for_messages(api, filter_func=update_filter):
|
for message in listen_for_messages(api, filter_func=update_filter):
|
||||||
# formatted_messages = list(map(format_message, message))
|
formatted_messages = list(map(format_message, message))
|
||||||
# print('\n---\n'.join(formatted_messages))
|
print('\n---\n'.join(formatted_messages))
|
||||||
# for message in formatted_messages:
|
for message in formatted_messages:
|
||||||
# send_message(owner_id, message, bot_token)
|
send_message(owner_id, message, bot_token)
|
||||||
# update_filter.update()
|
update_filter.update()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
IFNAME="wg_lva"
|
PIPE="/var/run/vpnd.sock"
|
||||||
|
send_cmd() {
|
||||||
|
[ -p $PIPE ] && echo "$@" > $PIPE && \
|
||||||
|
cat < $PIPE
|
||||||
|
}
|
||||||
|
|
||||||
|
IFNAME="rix"
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
'd'|'-d'|'--dpi') DPI="_d"
|
'm'|'msk') IFNAME='msk';;
|
||||||
;;
|
'-v'|'--verbose') VERBOSE=1;;
|
||||||
'm'|'msk') IFNAME='wg_msk'
|
*) echo "Wrong argument!"; exit 1;;
|
||||||
;;
|
|
||||||
'-v'|'--verbose') VERBOSE=1
|
|
||||||
;;
|
|
||||||
*) echo "Wrong argument!"; exit 1
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
@ -22,18 +23,17 @@ else
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
UP_NAME="$(ip link show | grep 'wg' | cut -d ' ' -f 2 | sed 's/://')"
|
UP_NAME="$(send_cmd status)"
|
||||||
|
|
||||||
IFNAME="${IFNAME}${DPI}"
|
|
||||||
if [ -n "${UP_NAME}" ]; then
|
if [ -n "${UP_NAME}" ]; then
|
||||||
if [ "${UP_NAME}" != "${IFNAME}" ]; then
|
if [ "${UP_NAME}" != "${IFNAME}" ]; then
|
||||||
wg-quick down "${UP_NAME}"
|
send_cmd down
|
||||||
wg-quick up "${IFNAME}"
|
send_cmd up "$IFNAME"
|
||||||
else
|
else
|
||||||
wg-quick down "${UP_NAME}"
|
send_cmd down
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
wg-quick up "${IFNAME}"
|
send_cmd up "$IFNAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pkill -36 dwmblocks
|
pkill -36 dwmblocks
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
|
[ -n "$oc_pid" ] && kill -s TERM $oc_pid
|
||||||
echo "exitting..."
|
echo "exitting..."
|
||||||
rm -f $PIPE
|
rm -f $PIPE
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -11,6 +12,7 @@ trap 'die' SIGTERM SIGQUIT SIGINT
|
||||||
|
|
||||||
PIPE="/var/run/vpnd.sock"
|
PIPE="/var/run/vpnd.sock"
|
||||||
oc_pid=
|
oc_pid=
|
||||||
|
up_name=
|
||||||
|
|
||||||
[ -p $PIPE ] && exit 1
|
[ -p $PIPE ] && exit 1
|
||||||
[ "$(id -u)" != "0" ] && exit 1
|
[ "$(id -u)" != "0" ] && exit 1
|
||||||
|
@ -21,7 +23,7 @@ for config in /etc/openconnect/config_*; do
|
||||||
CONFIGS+=("${config#config_}")
|
CONFIGS+=("${config#config_}")
|
||||||
done
|
done
|
||||||
|
|
||||||
COMMANDS=("up" "down")
|
COMMANDS=("up" "down" "status")
|
||||||
|
|
||||||
in_arr() {
|
in_arr() {
|
||||||
declare -n arr="$2"
|
declare -n arr="$2"
|
||||||
|
@ -37,12 +39,22 @@ down() {
|
||||||
kill -s TERM $oc_pid
|
kill -s TERM $oc_pid
|
||||||
wait $oc_pid
|
wait $oc_pid
|
||||||
oc_pid=
|
oc_pid=
|
||||||
|
up_name=
|
||||||
}
|
}
|
||||||
|
|
||||||
up() {
|
up() {
|
||||||
[ -n "$oc_pid" ] && down
|
[ -n "$oc_pid" ] && down
|
||||||
openconnect --config "/etc/openconnect/config_$1" &
|
openconnect --config "/etc/openconnect/config_$1" &
|
||||||
oc_pid="$!"
|
oc_pid="$!"
|
||||||
|
up_name="$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
status() {
|
||||||
|
# if [ -z "$up_name" ]; then
|
||||||
|
# echo "DOWN" > $PIPE
|
||||||
|
# else
|
||||||
|
# fi
|
||||||
|
echo "$up_name" > $PIPE
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
@ -50,18 +62,25 @@ main() {
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
read -r cmd ifname < $PIPE
|
read -r cmd ifname < $PIPE
|
||||||
|
if ! in_arr "$cmd" "COMMANDS"; then
|
||||||
if ! in_arr "$ifname" "CONFIGS"; then
|
|
||||||
echo "ERROR: Invalid interface $ifname" > $PIPE
|
|
||||||
elif ! in_arr "$cmd" "COMMANDS"; then
|
|
||||||
echo "ERROR: Invalid command $cmd" > $PIPE
|
echo "ERROR: Invalid command $cmd" > $PIPE
|
||||||
else
|
else
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
"up") up "$ifname" > $PIPE ;;
|
"up")
|
||||||
"down") down > $PIPE ;;
|
if ! in_arr "$ifname" "CONFIGS"; then
|
||||||
|
echo "ERROR: Invalid interface $ifname" > $PIPE
|
||||||
|
else
|
||||||
|
up "$ifname"
|
||||||
|
echo "$ifname" > $PIPE
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"down") down; echo "down" > $PIPE;;
|
||||||
|
"status") status;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "Running..."
|
||||||
main
|
main
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
PIPE="/var/run/vpnd.sock"
|
|
||||||
|
|
||||||
[ -p $PIPE ] &&
|
|
||||||
echo "$@" > $PIPE &&
|
|
||||||
cat < $PIPE
|
|
|
@ -25,14 +25,13 @@ remove() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
create_or_activate() {
|
create_or_activate() {
|
||||||
# shellcheck disable=SC1091
|
if [ ! -d "${VENV_FOLDER}" ]; then
|
||||||
if [ -d "${VENV_FOLDER}" ]; then
|
|
||||||
source "${VENV_FOLDER}/bin/activate"
|
|
||||||
else
|
|
||||||
python3 -m venv "${VENV_FOLDER}"
|
python3 -m venv "${VENV_FOLDER}"
|
||||||
source "${VENV_FOLDER}/bin/activate"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
source "${VENV_FOLDER}/bin/activate"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
IFNAME="$(ip link show | grep 'wg_' | cut -d ' ' -f 2 | sed 's/://' | sed 's/wg_//' | tr '[:lower:]' '[:upper:]' | sed 's/_D/ (dpi)/')"
|
|
||||||
|
|
||||||
if [ -n "${IFNAME}" ]; then
|
PIPE="/var/run/vpnd.sock"
|
||||||
echo " ${IFNAME}"
|
send_cmd() {
|
||||||
|
[ -p $PIPE ] && echo "$@" > $PIPE && \
|
||||||
|
cat < $PIPE
|
||||||
|
}
|
||||||
|
|
||||||
|
IFNAME="$(send_cmd status)"
|
||||||
|
|
||||||
|
case "$IFNAME" in
|
||||||
|
"msk") IFNAME="Moscow";;
|
||||||
|
"rix") IFNAME="Riga";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -n "$IFNAME" ]; then
|
||||||
|
echo " $IFNAME"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -6,6 +6,10 @@ Host *.zvray.ru *.wzray.com *.vpn.wzray.ru
|
||||||
User root
|
User root
|
||||||
Port 8022
|
Port 8022
|
||||||
|
|
||||||
|
Host docker
|
||||||
|
User root
|
||||||
|
Hostname 10.161.192.10
|
||||||
|
|
||||||
Host 192.168.1.1 10.161.0.1 10.162.0.1 openwrt
|
Host 192.168.1.1 10.161.0.1 10.162.0.1 openwrt
|
||||||
User root
|
User root
|
||||||
UserKnownHostsFile /dev/null
|
UserKnownHostsFile /dev/null
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue