Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kewek sub1 #6

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/create.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "🌲 Create Branches"
name: "🌲 Create Dev Branches"

on:
workflow_dispatch:

jobs:
create_branches:
runs-on: ubuntu-latest
name: "🌲 Create Branches"
name: "🌲 Create Dev Branches"
env:
EMAIL: ${{ secrets.GH_MAIL }}
NAME: ${{ secrets.GH_USER }}
Expand All @@ -28,11 +28,12 @@ jobs:
- name: 🌿 Push Branches
run: |
cd $(echo ${{github.repository}} | awk -F'/' '{print $2}')
git checkout dev
for ((i=1; i<=${{ env.BRANCH_COUNT }}; i++)); do
branch_name="${{ env.BRANCH_BASE_NAME }}${i}"
git branch $branch_name
git checkout $branch_name
git commit --allow-empty -m "Init ${branch_name}"
git push origin $branch_name
git checkout master
git checkout dev
done
6 changes: 3 additions & 3 deletions .github/workflows/delete.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: "🌿 Delete Branches"
name: "🌿 Delete Dev Branches"

on:
workflow_dispatch:

jobs:
create_branches:
runs-on: ubuntu-latest
name: "🌲 Delete Branches"
name: "🌲 Delete Dev Branches"
env:
EMAIL: ${{ secrets.GH_MAIL }}
NAME: ${{ secrets.GH_USER }}
TOKEN: ${{ secrets.GH_TOKEN }}
BRANCH_BASE_NAME: x
BRANCH_COUNT: 300
BRANCH_COUNT: 100

steps:
- name: ⚙️ Setup
Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: ⛅ Deploy Workers
name: ⛅ Deploy Dev Workers
on:
push:
branches:
- '**' # All branch
- '!master' # Excludes master
pull_request:
repository_dispatch:
branches:
- '**' # All branch
- '!master' # Excludes master
jobs:
deploy:
runs-on: ubuntu-latest
Expand All @@ -14,7 +19,11 @@ jobs:
node-version: 18
cache: 'npm'
- run: npm i
- run: sed -i s/KV_NAME/${{ secrets.KV_NAME }}/g wrangler.toml
- run: sed -i s/IPPROXYHERE/170.187.226.208/g src/panel.ts
- run: cat src/panel.ts
- run: sed -i s/IPPROXYHERE/170.187.226.208/g src/vless.ts
- run: sed -i s/vpn/${{ github.ref_name }}/g wrangler.toml
- run: sed -i s/KV_DEV/${{ secrets.KV_DEV }}/g wrangler.toml
- name: Build & Deploy Worker
uses: cloudflare/wrangler-action@v3
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "🔄 Sync"
name: "🔄 Sync Dev Branches"

on:
workflow_dispatch:

jobs:
sync_branches:
runs-on: ubuntu-latest
name: "🔄 Sync branches with master"
name: "🔄 Sync branches with dev"
env:
EMAIL: ${{ secrets.GH_MAIL }}
NAME: ${{ secrets.GH_USER }}
Expand All @@ -28,12 +28,12 @@ jobs:
- name: 🔄 Sync
run: |
cd $(echo ${{github.repository}} | awk -F'/' '{print $2}')
git checkout master
git pull origin master
git checkout dev
git pull origin dev
for ((i=1; i<=${{ env.BRANCH_COUNT }}; i++)); do
branch_name="${{ env.BRANCH_BASE_NAME }}${i}"
git checkout $branch_name
git merge main --no-edit
git push origin $branch_name
git checkout master
git checkout dev
done
4 changes: 2 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ export async function PostLogin(request: Request, env: Env): Promise<Response> {
const url: URL = new URL(request.url)
const formData = await request.formData()
const password: string = formData.get("password") || ""
let hashedPassword: string = await env.settings.get("Password") || ""
let hashedPassword: string = await env.configs.get("Password") || ""
await Delay(1000)
const match = await bcrypt.compare(password, hashedPassword)

if (match) {
const token: string = GenerateToken(24)
await env.settings.put("Token", token)
await env.configs.put("Token", token)
return Response.redirect(`${url.protocol}//${url.hostname}${url.port != "443" ? ":" + url.port : ""}/?token=${token}`, 302)
}

Expand Down
20 changes: 10 additions & 10 deletions src/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ export async function GetConfigList(url: URL, env: Env): Promise<Array<Config>>
let settingsNotAvailable: boolean = true

try {
maxConfigs = parseInt(await env.settings.get("MaxConfigs") || "10")
maxConfigs = parseInt(await env.configs.get("MaxConfigs") || "10")
if (maxConfigs > 10) {
maxVlessConfigs = 1
}
protocols = await env.settings.get("Protocols").then(val => {return val ? val.split("\n") : []})
protocols = await env.configs.get("Protocols").then(val => {return val ? val.split("\n") : []})
if (protocols.includes("vless")) {
maxConfigs = maxConfigs - maxVlessConfigs
}
providers = await env.settings.get("Providers").then(val => {return val ? val.split("\n") : []})
alpnList = await env.settings.get("ALPNs").then(val => {return val ? val.split("\n") : []})
fingerPrints = await env.settings.get("FingerPrints").then(val => {return val ? val.split("\n") : []})
includeOriginalConfigs = (await env.settings.get("IncludeOriginalConfigs") || "yes") == "yes"
includeMergedConfigs = ((await env.settings.get("IncludeMergedConfigs") || "yes") == "yes") && protocols.includes("vmess")
cleanDomainIPs = await env.settings.get("CleanDomainIPs").then(val => {return val ? val.split("\n") : []})
settingsNotAvailable = (await env.settings.get("MaxConfigs")) === null
myConfigs = (await env.settings.get("Configs"))?.split("\n") || []
providers = await env.configs.get("Providers").then(val => {return val ? val.split("\n") : []})
alpnList = await env.configs.get("ALPNs").then(val => {return val ? val.split("\n") : []})
fingerPrints = await env.configs.get("FingerPrints").then(val => {return val ? val.split("\n") : []})
includeOriginalConfigs = (await env.configs.get("IncludeOriginalConfigs") || "yes") == "yes"
includeMergedConfigs = ((await env.configs.get("IncludeMergedConfigs") || "yes") == "yes") && protocols.includes("vmess")
cleanDomainIPs = await env.configs.get("CleanDomainIPs").then(val => {return val ? val.split("\n") : []})
settingsNotAvailable = (await env.configs.get("MaxConfigs")) === null
myConfigs = (await env.configs.get("Configs"))?.split("\n") || []
} catch { }

if (settingsNotAvailable) {
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ export interface WSHeaders {
}

export interface Env {
settings: KVNamespace
configs: KVNamespace
}
92 changes: 46 additions & 46 deletions src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import { Env } from "./interfaces"
export async function GetPanel(request: Request, env: Env): Promise<Response> {
const url: URL = new URL(request.url)
try {
const hash: string | null = await env.settings.get("Password")
const token: string | null = await env.settings.get("Token")
const hash: string | null = await env.configs.get("Password")
const token: string | null = await env.configs.get("Token")

if (hash && url.searchParams.get("token") != token) {
return Response.redirect(`${url.protocol}//${url.hostname}${url.port != "443" ? ":" + url.port : ""}/login`, 302)
}

const proxyIP: string = await env.settings.get("ProxyIP") || "8.222.193.65"
const maxConfigs: number = parseInt(await env.settings.get("MaxConfigs") || "10")
const protocols: Array<string> = (await env.settings.get("Protocols"))?.split("\n") || defaultProtocols
const alpnList: Array<string> = (await env.settings.get("ALPNs"))?.split("\n") || defaultALPNList
const fingerPrints: Array<string> = (await env.settings.get("FingerPrints"))?.split("\n") || defaultPFList
const providers: Array<string> = (await env.settings.get("Providers"))?.split("\n") || defaultProviders
const cleanDomainIPs: Array<string> = (await env.settings.get("CleanDomainIPs"))?.split("\n") || []
const configs: Array<string> = (await env.settings.get("Configs"))?.split("\n") || []
const includeOriginalConfigs: string = await env.settings.get("IncludeOriginalConfigs") || "yes"
const includeMergedConfigs: string = await env.settings.get("IncludeMergedConfigs") || "yes"
const proxyIP: string = "IPPROXYHERE"
const maxConfigs: number = parseInt(await env.configs.get("MaxConfigs") || "10")
const protocols: Array<string> = (await env.configs.get("Protocols"))?.split("\n") || defaultProtocols
const alpnList: Array<string> = (await env.configs.get("ALPNs"))?.split("\n") || defaultALPNList
const fingerPrints: Array<string> = (await env.configs.get("FingerPrints"))?.split("\n") || defaultPFList
const providers: Array<string> = (await env.configs.get("Providers"))?.split("\n") || defaultProviders
const cleanDomainIPs: Array<string> = (await env.configs.get("CleanDomainIPs"))?.split("\n") || []
const configs: Array<string> = (await env.configs.get("Configs"))?.split("\n") || []
const includeOriginalConfigs: string = await env.configs.get("IncludeOriginalConfigs") || "yes"
const includeMergedConfigs: string = await env.configs.get("IncludeMergedConfigs") || "yes"

var uuid: string = await env.settings.get("UUID") || ""
var uuid: string = await env.configs.get("UUID") || ""
if (!IsValidUUID(uuid)) {
uuid = uuidv4()
await env.settings.put("UUID", uuid)
await env.configs.put("UUID", uuid)
}

var htmlMessage = ""
Expand Down Expand Up @@ -119,13 +119,13 @@ export async function GetPanel(request: Request, env: Env): Promise<Response> {
</div>
</div>
</div>
<div class="mb-1 p-1">
<!--div class="mb-1 p-1">
<label for="proxy-ip" class="form-label fw-bold">
IP Proxy :
</label>
<input type="text" name="proxy-ip" class="form-control" id="proxy-ip" value="${proxyIP}" />
<div class="form-text"></div>
</div>
</div-->
<div class="mb-1 p-1">
<label for="max-configs" class="form-label fw-bold">
Jumlah Proxy :
Expand Down Expand Up @@ -277,7 +277,7 @@ export async function GetPanel(request: Request, env: Env): Promise<Response> {
</div>

<div class="form-group col-md-6 mx-auto mx-5 my-2 p-1 border bg-danger text-center">
<p>Variabel "settings" tidak ditemukan ! Silahkan buat namespace di Workers / KV ! Tambahkan variabel "settings" di pengaturan workers.</p>
<p>Variabel "configs" tidak ditemukan ! Silahkan buat namespace di Workers / KV ! Tambahkan variabel "configs" di pengaturan workers.</p>
</div>
<div class="form-group col-md-6 mx-auto mx-5 my-2 p-1 border bg-success text-white text-center">
<p>Anda bisa menggunakan BITS VPN tanpa BITS VPN Dashboard.</p>
Expand All @@ -293,18 +293,18 @@ export async function GetPanel(request: Request, env: Env): Promise<Response> {

export async function PostPanel(request: Request, env: Env): Promise<Response> {
const url: URL = new URL(request.url)
var token: string | null = await env.settings.get("Token")
var token: string | null = await env.configs.get("Token")
try {
const formData = await request.formData()
var hashedPassword: string | null = await env.settings.get("Password")
var hashedPassword: string | null = await env.configs.get("Password")

if (hashedPassword && url.searchParams.get("token") != token) {
return Response.redirect(`${url.protocol}//${url.hostname}${url.port != "443" ? ":" + url.port : ""}/login`, 302)
}

if (formData.get("reset_password")) {
await env.settings.delete("Password")
await env.settings.delete("Token")
await env.configs.delete("Password")
await env.configs.delete("Token")
return Response.redirect(`${url.protocol}//${url.hostname}${url.port != "443" ? ":" + url.port : ""}?message=success`, 302)
} else if (formData.get("save")) {
const password: string | null = formData.get("password")
Expand All @@ -314,34 +314,34 @@ export async function PostPanel(request: Request, env: Env): Promise<Response> {
}
hashedPassword = await bcrypt.hash(password, 10);
token = GenerateToken(24)
await env.settings.put("Password", hashedPassword)
await env.settings.put("Token", token)
await env.configs.put("Password", hashedPassword)
await env.configs.put("Token", token)
}

await env.settings.put("ProxyIP", formData.get("proxy-ip") || "8.222.193.65")
await env.settings.put("MaxConfigs", formData.get("max") || "200")
await env.settings.put("Protocols", formData.getAll("protocols")?.join("\n").trim())
await env.settings.put("ALPNs", formData.get("alpn_list")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.settings.put("FingerPrints", formData.get("fp_list")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.settings.put("Providers", formData.get("providers")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.settings.put("CleanDomainIPs", formData.get("clean_ips")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.settings.put("Configs", formData.get("configs")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.settings.put("IncludeOriginalConfigs", formData.get("original") || "no")
await env.settings.put("IncludeMergedConfigs", formData.get("merged") || "no")
await env.configs.put("ProxyIP", "IPPROXYHERE")
await env.configs.put("MaxConfigs", formData.get("max") || "200")
await env.configs.put("Protocols", formData.getAll("protocols")?.join("\n").trim())
await env.configs.put("ALPNs", formData.get("alpn_list")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.configs.put("FingerPrints", formData.get("fp_list")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.configs.put("Providers", formData.get("providers")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.configs.put("CleanDomainIPs", formData.get("clean_ips")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.configs.put("Configs", formData.get("configs")?.trim().split("\n").map(str => str.trim()).join("\n") || "")
await env.configs.put("IncludeOriginalConfigs", formData.get("original") || "no")
await env.configs.put("IncludeMergedConfigs", formData.get("merged") || "no")
} else {
await env.settings.delete("ProxyIP")
await env.settings.delete("MaxConfigs")
await env.settings.delete("Protocols")
await env.settings.delete("ALPNs")
await env.settings.delete("FingerPrints")
await env.settings.delete("Providers")
await env.settings.delete("CleanDomainIPs")
await env.settings.delete("Configs")
await env.settings.delete("IncludeOriginalConfigs")
await env.settings.delete("IncludeMergedConfigs")
await env.settings.delete("UUID")
await env.settings.delete("Password")
await env.settings.delete("Token")
await env.configs.delete("ProxyIP")
await env.configs.delete("MaxConfigs")
await env.configs.delete("Protocols")
await env.configs.delete("ALPNs")
await env.configs.delete("FingerPrints")
await env.configs.delete("Providers")
await env.configs.delete("CleanDomainIPs")
await env.configs.delete("Configs")
await env.configs.delete("IncludeOriginalConfigs")
await env.configs.delete("IncludeMergedConfigs")
await env.configs.delete("UUID")
await env.configs.delete("Password")
await env.configs.delete("Token")
}

return Response.redirect(`${url.protocol}//${url.hostname}${url.port != "443" ? ":" + url.port : ""}?message=success${token ? "&token=" + token : ""}`, 302)
Expand Down
12 changes: 6 additions & 6 deletions src/vless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { RemoteSocketWrapper, CustomArrayBuffer, VlessHeader, UDPOutbound, Confi

const WS_READY_STATE_OPEN: number = 1
const WS_READY_STATE_CLOSING: number = 2
let uuid: string = ""
let proxyIP: string = ""
let uuid: string = "fef47eb7-884d-4490-8181-74481de3b428"
let proxyIP: string = "IPPROXYHERE"

export async function GetVlessConfigList(sni: string, addressList: Array<string>, max: number, env: Env) {
let uuid: string | null = await env.settings.get("UUID")
let proxyIP: string | null = await env.settings.get("ProxyIP")
let uuid: string | null = "fef47eb7-884d-4490-8181-74481de3b428"
let proxyIP: string | null = "IPPROXYHERE"
let configList: Array<Config> = []
if (uuid) {
for (let i = 0; i < max; i++) {
Expand All @@ -29,8 +29,8 @@ export async function GetVlessConfigList(sni: string, addressList: Array<string>
}

export async function VlessOverWSHandler(request: Request, env: Env) {
uuid = uuid || await env.settings.get("UUID") || ""
proxyIP = await env.settings.get("ProxyIP")
uuid = "fef47eb7-884d-4490-8181-74481de3b428"
proxyIP = "IPPROXYHERE"
const [client, webSocket]: Array<WebSocket> = Object.values(new WebSocketPair)

webSocket.accept()
Expand Down
4 changes: 2 additions & 2 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "bits"
name = "vpn"
main = "src/worker.ts"
compatibility_date = "2024-01-01"

kv_namespaces = [
{ binding = "settings", id = "KV_NAME" }
{ binding = "configs", id = "KV_DEV" }
]