mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
Compare commits
2 Commits
4.1.1
...
test-release
| Author | SHA1 | Date | |
|---|---|---|---|
| 6631ebcf49 | |||
| c28e157616 |
@@ -10,64 +10,120 @@ jobs:
|
|||||||
notify:
|
notify:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Send to Telegram
|
- name: Send to Telegram - New Issue
|
||||||
|
if: github.event_name == 'issues' && github.event.action == 'opened'
|
||||||
|
env:
|
||||||
|
TITLE: ${{ github.event.issue.title }}
|
||||||
|
NUMBER: ${{ github.event.issue.number }}
|
||||||
|
USER: ${{ github.event.issue.user.login }}
|
||||||
|
BODY: ${{ github.event.issue.body || 'No body provided' }}
|
||||||
|
URL: ${{ github.event.issue.html_url }}
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ github.event_name }}" == "issues" && "${{ github.event.action }}" == "opened" ]]; then
|
BODY_TRUNC="${BODY:0:200}" # Truncate to avoid spam
|
||||||
TITLE="${{ github.event.issue.title }}"
|
TEXT=$(echo -e "🆕 New Issue #$NUMBER: *$TITLE* by $USER\n\n$BODY_TRUNC\n\n[View Issue]($URL)")
|
||||||
NUMBER=${{ github.event.issue.number }}
|
|
||||||
USER="${{ github.event.issue.user.login }}"
|
|
||||||
BODY="${{ github.event.issue.body || 'No body provided' }}"
|
|
||||||
BODY_TRUNC="${BODY:0:200}" # Truncate to avoid spam
|
|
||||||
URL="${{ github.event.issue.html_url }}"
|
|
||||||
TEXT=$(echo -e "🆕 New Issue #$NUMBER: *$TITLE* by $USER\n\n$BODY_TRUNC\n\n[View Issue]($URL)")
|
|
||||||
elif [[ "${{ github.event_name }}" == "issues" && "${{ github.event.action }}" == "closed" ]]; then
|
|
||||||
TITLE="${{ github.event.issue.title }}"
|
|
||||||
NUMBER=${{ github.event.issue.number }}
|
|
||||||
USER="${{ github.event.issue.user.login }}"
|
|
||||||
URL="${{ github.event.issue.html_url }}"
|
|
||||||
TEXT=$(echo -e "✅ Issue Closed #$NUMBER: *$TITLE* by $USER\n\n[View Issue]($URL)")
|
|
||||||
elif [[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "published" ]]; then
|
|
||||||
NAME="${{ github.event.release.name }}"
|
|
||||||
TAG="${{ github.event.release.tag_name }}"
|
|
||||||
BODY="${{ github.event.release.body || 'No notes provided' }}"
|
|
||||||
BODY_TRUNC="${BODY:0:200}" # Truncate to avoid spam
|
|
||||||
URL="${{ github.event.release.html_url }}"
|
|
||||||
TEXT=$(echo -e "🚀 New Release *$NAME* ($TAG)\n\n$BODY_TRUNC\n\n[View Release]($URL)")
|
|
||||||
fi
|
|
||||||
|
|
||||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \
|
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \
|
||||||
-d chat_id="${{ vars.TELEGRAM_CHAT_ID }}" \
|
-d chat_id="${{ vars.TELEGRAM_CHAT_ID }}" \
|
||||||
${{ vars.TELEGRAM_THREAD_ID && format('-d message_thread_id="{0}"', vars.TELEGRAM_THREAD_ID) || '' }} \
|
${{ vars.TELEGRAM_THREAD_ID && format('-d message_thread_id="{0}"', vars.TELEGRAM_THREAD_ID) || '' }} \
|
||||||
-d parse_mode="Markdown" \
|
-d parse_mode="Markdown" \
|
||||||
--data-urlencode "text=$TEXT"
|
--data-urlencode "text=$TEXT"
|
||||||
|
|
||||||
- name: Send to Matrix
|
- name: Send to Telegram - Closed Issue
|
||||||
|
if: github.event_name == 'issues' && github.event.action == 'closed'
|
||||||
|
env:
|
||||||
|
TITLE: ${{ github.event.issue.title }}
|
||||||
|
NUMBER: ${{ github.event.issue.number }}
|
||||||
|
USER: ${{ github.event.issue.user.login }}
|
||||||
|
URL: ${{ github.event.issue.html_url }}
|
||||||
run: |
|
run: |
|
||||||
PLAIN_MESSAGE=""
|
TEXT=$(echo -e "✅ Issue Closed #$NUMBER: *$TITLE* by $USER\n\n[View Issue]($URL)")
|
||||||
HTML_MESSAGE=""
|
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \
|
||||||
if [[ "${{ github.event_name }}" == "issues" && "${{ github.event.action }}" == "opened" ]]; then
|
-d chat_id="${{ vars.TELEGRAM_CHAT_ID }}" \
|
||||||
PLAIN_MESSAGE=$(echo -e "🆕 New Issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }} by ${{ github.event.issue.user.login }}\n\n${{ github.event.issue.body || 'No body provided' }}\n\nView Issue: ${{ github.event.issue.html_url }}")
|
${{ vars.TELEGRAM_THREAD_ID && format('-d message_thread_id="{0}"', vars.TELEGRAM_THREAD_ID) || '' }} \
|
||||||
HTML_MESSAGE=$(echo -e "<p>🆕 New Issue #${{ github.event.issue.number }}: <strong>${{ github.event.issue.title }}</strong> by ${{ github.event.issue.user.login }}</p><p>${{ github.event.issue.body || 'No body provided' }}</p><p><a href=\"${{ github.event.issue.html_url }}\">View Issue</a></p>")
|
-d parse_mode="Markdown" \
|
||||||
elif [[ "${{ github.event_name }}" == "issues" && "${{ github.event.action }}" == "closed" ]]; then
|
--data-urlencode "text=$TEXT"
|
||||||
PLAIN_MESSAGE=$(echo -e "✅ Issue Closed #${{ github.event.issue.number }}: ${{ github.event.issue.title }} by ${{ github.event.issue.user.login }}\n\nView Issue: ${{ github.event.issue.html_url }}")
|
|
||||||
HTML_MESSAGE=$(echo -e "<p>✅ Issue Closed #${{ github.event.issue.number }}: <strong>${{ github.event.issue.title }}</strong> by ${{ github.event.issue.user.login }}</p><p><a href=\"${{ github.event.issue.html_url }}\">View Issue</a></p>")
|
|
||||||
elif [[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "published" ]]; then
|
|
||||||
PLAIN_MESSAGE=$(echo -e "🚀 New Release ${{ github.event.release.name }} (${{ github.event.release.tag_name }})\n\n${{ github.event.release.body || 'No notes provided' }}\n\nView Release: ${{ github.event.release.html_url }}")
|
|
||||||
HTML_MESSAGE=$(echo -e "<p>🚀 New Release <strong>${{ github.event.release.name }}</strong> (${{ github.event.release.tag_name }})</p><p>${{ github.event.release.body || 'No notes provided' }}</p><p><a href=\"${{ github.event.release.html_url }}\">View Release</a></p>")
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
- name: Send to Telegram - New Release
|
||||||
|
if: github.event_name == 'release' && github.event.action == 'published'
|
||||||
|
env:
|
||||||
|
NAME: ${{ github.event.release.name }}
|
||||||
|
TAG: ${{ github.event.release.tag_name }}
|
||||||
|
BODY: ${{ github.event.release.body || 'No notes provided' }}
|
||||||
|
URL: ${{ github.event.release.html_url }}
|
||||||
|
run: |
|
||||||
|
BODY_TRUNC="${BODY:0:200}" # Truncate to avoid spam
|
||||||
|
TEXT=$(echo -e "🚀 New Release *$NAME* ($TAG)\n\n$BODY_TRUNC\n\n[View Release]($URL)")
|
||||||
|
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \
|
||||||
|
-d chat_id="${{ vars.TELEGRAM_CHAT_ID }}" \
|
||||||
|
${{ vars.TELEGRAM_THREAD_ID && format('-d message_thread_id="{0}"', vars.TELEGRAM_THREAD_ID) || '' }} \
|
||||||
|
-d parse_mode="Markdown" \
|
||||||
|
--data-urlencode "text=$TEXT"
|
||||||
|
|
||||||
|
- name: Send to Matrix - New Issue
|
||||||
|
if: github.event_name == 'issues' && github.event.action == 'opened'
|
||||||
|
env:
|
||||||
|
NUMBER: ${{ github.event.issue.number }}
|
||||||
|
TITLE: ${{ github.event.issue.title }}
|
||||||
|
USER: ${{ github.event.issue.user.login }}
|
||||||
|
BODY: ${{ github.event.issue.body || 'No body provided' }}
|
||||||
|
URL: ${{ github.event.issue.html_url }}
|
||||||
|
run: |
|
||||||
|
PLAIN_MESSAGE=$(echo -e "🆕 New Issue #$NUMBER: $TITLE by $USER\n\n$BODY\n\nView Issue: $URL")
|
||||||
|
HTML_MESSAGE=$(echo -e "<p>🆕 New Issue #$NUMBER: <strong>$TITLE</strong> by $USER</p><p>$BODY</p><p><a href=\"$URL\">View Issue</a></p>")
|
||||||
PLAIN_MESSAGE="${PLAIN_MESSAGE:0:220}"
|
PLAIN_MESSAGE="${PLAIN_MESSAGE:0:220}"
|
||||||
|
|
||||||
PAYLOAD=$(jq -n --arg body "$PLAIN_MESSAGE" --arg formatted "$HTML_MESSAGE" '{
|
PAYLOAD=$(jq -n --arg body "$PLAIN_MESSAGE" --arg formatted "$HTML_MESSAGE" '{
|
||||||
"msgtype": "m.text",
|
"msgtype": "m.text",
|
||||||
"body": $body,
|
"body": $body,
|
||||||
"format": "org.matrix.custom.html",
|
"format": "org.matrix.custom.html",
|
||||||
"formatted_body": $formatted
|
"formatted_body": $formatted
|
||||||
}')
|
}')
|
||||||
|
|
||||||
TXN_ID="${{ github.run_id }}-${{ github.run_attempt }}"
|
TXN_ID="${{ github.run_id }}-${{ github.run_attempt }}"
|
||||||
|
|
||||||
curl -s -X PUT "https://${{ vars.MATRIX_HOMESERVER }}/_matrix/client/v3/rooms/${{ vars.MATRIX_ROOM_ID }}/send/m.room.message/$TXN_ID" \
|
curl -s -X PUT "https://${{ vars.MATRIX_HOMESERVER }}/_matrix/client/v3/rooms/${{ vars.MATRIX_ROOM_ID }}/send/m.room.message/$TXN_ID" \
|
||||||
-H "Authorization: Bearer ${{ secrets.MATRIX_ACCESS_TOKEN }}" \
|
-H "Authorization: Bearer ${{ secrets.MATRIX_ACCESS_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$PAYLOAD"
|
-d "$PAYLOAD"
|
||||||
|
|
||||||
|
- name: Send to Matrix - Closed Issue
|
||||||
|
if: github.event_name == 'issues' && github.event.action == 'closed'
|
||||||
|
env:
|
||||||
|
NUMBER: ${{ github.event.issue.number }}
|
||||||
|
TITLE: ${{ github.event.issue.title }}
|
||||||
|
USER: ${{ github.event.issue.user.login }}
|
||||||
|
URL: ${{ github.event.issue.html_url }}
|
||||||
|
run: |
|
||||||
|
PLAIN_MESSAGE=$(echo -e "✅ Issue Closed #$NUMBER: $TITLE by $USER\n\nView Issue: $URL")
|
||||||
|
HTML_MESSAGE=$(echo -e "<p>✅ Issue Closed #$NUMBER: <strong>$TITLE</strong> by $USER</p><p><a href=\"$URL\">View Issue</a></p>")
|
||||||
|
PLAIN_MESSAGE="${PLAIN_MESSAGE:0:220}"
|
||||||
|
PAYLOAD=$(jq -n --arg body "$PLAIN_MESSAGE" --arg formatted "$HTML_MESSAGE" '{
|
||||||
|
"msgtype": "m.text",
|
||||||
|
"body": $body,
|
||||||
|
"format": "org.matrix.custom.html",
|
||||||
|
"formatted_body": $formatted
|
||||||
|
}')
|
||||||
|
TXN_ID="${{ github.run_id }}-${{ github.run_attempt }}"
|
||||||
|
curl -s -X PUT "https://${{ vars.MATRIX_HOMESERVER }}/_matrix/client/v3/rooms/${{ vars.MATRIX_ROOM_ID }}/send/m.room.message/$TXN_ID" \
|
||||||
|
-H "Authorization: Bearer ${{ secrets.MATRIX_ACCESS_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$PAYLOAD"
|
||||||
|
|
||||||
|
- name: Send to Matrix - New Release
|
||||||
|
if: github.event_name == 'release' && github.event.action == 'published'
|
||||||
|
env:
|
||||||
|
NAME: ${{ github.event.release.name }}
|
||||||
|
TAG: ${{ github.event.release.tag_name }}
|
||||||
|
BODY: ${{ github.event.release.body || 'No notes provided' }}
|
||||||
|
URL: ${{ github.event.release.html_url }}
|
||||||
|
run: |
|
||||||
|
PLAIN_MESSAGE=$(echo -e "🚀 New Release $NAME ($TAG)\n\n$BODY\n\nView Release: $URL")
|
||||||
|
HTML_MESSAGE=$(echo -e "<p>🚀 New Release <strong>$NAME</strong> ($TAG)</p><p>$BODY</p><p><a href=\"$URL\">View Release</a></p>")
|
||||||
|
PLAIN_MESSAGE="${PLAIN_MESSAGE:0:220}"
|
||||||
|
PAYLOAD=$(jq -n --arg body "$PLAIN_MESSAGE" --arg formatted "$HTML_MESSAGE" '{
|
||||||
|
"msgtype": "m.text",
|
||||||
|
"body": $body,
|
||||||
|
"format": "org.matrix.custom.html",
|
||||||
|
"formatted_body": $formatted
|
||||||
|
}')
|
||||||
|
TXN_ID="${{ github.run_id }}-${{ github.run_attempt }}"
|
||||||
|
curl -s -X PUT "https://${{ vars.MATRIX_HOMESERVER }}/_matrix/client/v3/rooms/${{ vars.MATRIX_ROOM_ID }}/send/m.room.message/$TXN_ID" \
|
||||||
|
-H "Authorization: Bearer ${{ secrets.MATRIX_ACCESS_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$PAYLOAD"
|
||||||
+32
-21
@@ -325,6 +325,18 @@ constructor(
|
|||||||
proxyUserspaceTunnel.setBackendMode(BackendMode.Inactive)
|
proxyUserspaceTunnel.setBackendMode(BackendMode.Inactive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isVpnAuthorized(
|
||||||
|
mode: AppMode,
|
||||||
|
hasVpnPermission: () -> Boolean = { serviceManager.hasVpnPermission() },
|
||||||
|
): Boolean {
|
||||||
|
return when (mode) {
|
||||||
|
AppMode.VPN,
|
||||||
|
AppMode.LOCK_DOWN -> hasVpnPermission()
|
||||||
|
AppMode.KERNEL,
|
||||||
|
AppMode.PROXY -> true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun handleRestore() =
|
suspend fun handleRestore() =
|
||||||
withContext(ioDispatcher) {
|
withContext(ioDispatcher) {
|
||||||
val settings = settingsRepository.getGeneralSettings()
|
val settings = settingsRepository.getGeneralSettings()
|
||||||
@@ -332,18 +344,20 @@ constructor(
|
|||||||
val tunnels = tunnelsRepository.getAll()
|
val tunnels = tunnelsRepository.getAll()
|
||||||
if (autoTunnelSettings.isAutoTunnelEnabled)
|
if (autoTunnelSettings.isAutoTunnelEnabled)
|
||||||
return@withContext restoreAutoTunnel(autoTunnelSettings)
|
return@withContext restoreAutoTunnel(autoTunnelSettings)
|
||||||
when (val mode = settings.appMode) {
|
if (isVpnAuthorized(settings.appMode)) {
|
||||||
AppMode.VPN,
|
when (val mode = settings.appMode) {
|
||||||
AppMode.PROXY,
|
AppMode.VPN,
|
||||||
AppMode.LOCK_DOWN -> {
|
AppMode.PROXY,
|
||||||
if (serviceManager.hasVpnPermission()) {
|
AppMode.LOCK_DOWN -> {
|
||||||
if (mode == AppMode.LOCK_DOWN)
|
if (mode == AppMode.LOCK_DOWN)
|
||||||
handleLockDownModeInit(settings.isLanOnKillSwitchEnabled)
|
handleLockDownModeInit(settings.isLanOnKillSwitchEnabled)
|
||||||
tunnels.firstOrNull { it.isActive }?.let { startTunnel(it) }
|
tunnels.firstOrNull { it.isActive }?.let { startTunnel(it) }
|
||||||
} else localErrorEvents.emit(null to BackendCoreException.NotAuthorized)
|
}
|
||||||
|
AppMode.KERNEL ->
|
||||||
|
tunnels.filter { it.isActive }.forEach { conf -> startTunnel(conf) }
|
||||||
}
|
}
|
||||||
AppMode.KERNEL ->
|
} else {
|
||||||
tunnels.filter { it.isActive }.forEach { conf -> startTunnel(conf) }
|
localErrorEvents.emit(null to BackendCoreException.NotAuthorized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,21 +375,18 @@ constructor(
|
|||||||
return@withContext restoreAutoTunnel(autoTunnelSettings)
|
return@withContext restoreAutoTunnel(autoTunnelSettings)
|
||||||
if (settings.isRestoreOnBootEnabled) {
|
if (settings.isRestoreOnBootEnabled) {
|
||||||
tunnelsRepository.resetActiveTunnels()
|
tunnelsRepository.resetActiveTunnels()
|
||||||
when (val mode = settings.appMode) {
|
if (isVpnAuthorized(settings.appMode)) {
|
||||||
AppMode.VPN,
|
when (val mode = settings.appMode) {
|
||||||
AppMode.PROXY,
|
AppMode.LOCK_DOWN ->
|
||||||
AppMode.LOCK_DOWN -> {
|
handleLockDownModeInit(settings.isLanOnKillSwitchEnabled)
|
||||||
if (serviceManager.hasVpnPermission()) {
|
AppMode.KERNEL,
|
||||||
if (mode == AppMode.LOCK_DOWN)
|
AppMode.VPN,
|
||||||
handleLockDownModeInit(settings.isLanOnKillSwitchEnabled)
|
AppMode.PROXY -> Unit
|
||||||
} else
|
|
||||||
return@withContext localErrorEvents.emit(
|
|
||||||
null to BackendCoreException.NotAuthorized
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
AppMode.KERNEL -> Unit
|
defaultTunnel?.let { startTunnel(it) }
|
||||||
|
} else {
|
||||||
|
localErrorEvents.emit(null to BackendCoreException.NotAuthorized)
|
||||||
}
|
}
|
||||||
defaultTunnel?.let { startTunnel(it) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-7
@@ -35,14 +35,15 @@ fun TunnelStatisticsRow(
|
|||||||
val textColor = MaterialTheme.colorScheme.outline
|
val textColor = MaterialTheme.colorScheme.outline
|
||||||
|
|
||||||
// needs to be set as peer stats for duplicates return as a single set of stats
|
// needs to be set as peer stats for duplicates return as a single set of stats
|
||||||
val peers by remember(tunnel) {
|
val peers by
|
||||||
derivedStateOf {
|
remember(tunnel) {
|
||||||
TunnelConfig.configFromWgQuick(tunnel.wgQuick)
|
derivedStateOf {
|
||||||
.peers
|
TunnelConfig.configFromWgQuick(tunnel.wgQuick)
|
||||||
.map { it.publicKey.toBase64() }
|
.peers
|
||||||
.toSet()
|
.map { it.publicKey.toBase64() }
|
||||||
|
.toSet()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var currentTimeMillis by remember { mutableLongStateOf(System.currentTimeMillis()) }
|
var currentTimeMillis by remember { mutableLongStateOf(System.currentTimeMillis()) }
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
|
|||||||
Reference in New Issue
Block a user