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

Overview Page Route/Exit counts are incorrect #36

Closed
iFargle opened this issue Mar 3, 2023 · 3 comments
Closed

Overview Page Route/Exit counts are incorrect #36

iFargle opened this issue Mar 3, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@iFargle
Copy link
Owner

iFargle commented Mar 3, 2023

No description provided.

@iFargle iFargle added the bug Something isn't working label Mar 3, 2023
@iFargle iFargle self-assigned this Mar 3, 2023
@iFargle
Copy link
Owner Author

iFargle commented Mar 3, 2023

#!/bin/python3
import requests

def get_routes(url, api_key):
    response = requests.get(
        str(url)+"/api/v1/routes",
        headers={
            'Accept': 'application/json',
            'Authorization': 'Bearer '+str(api_key)
        }
    )
    return response.json()
routes  = get_routes(url, api_key)

print("|----|----------------------|----------------------|-------|-------|")
print("| ## | HOST (ID)            | ROUTE                | ADV   | ENAB  |")
print("|----|----------------------|----------------------|-------|-------|")
# Just print a table

for route in routes["routes"]:
    id      = str(route["id"]).ljust(2, ' ')
    host    = str(route["machine"]["name"])
    hostid  = str(route["machine"]["id"])
    hosts   = str(host+" ("+hostid+")").ljust(20, ' ')
    rt      = str(route["prefix"]).ljust(20, ' ')
    advert  = str(route["advertised"]).ljust(5, ' ')
    enabled = str(route["enabled"]).ljust(5, ' ')
    print("| "+id+" | "+hosts+" | "+rt+" | "+advert+" | "+enabled+" |")

print("|----|----------------------|----------------------|-------|-------|")

Outputs:

|----|----------------------|----------------------|-------|-------|
| ## | HOST (ID)            | ROUTE                | ADV   | ENAB  |
|----|----------------------|----------------------|-------|-------|
| 1  | nuc-docker01 (1)     | 0.0.0.0/0            | True  | True  |
| 2  | sysctl (13)          | 10.2.0.0/24          | True  | True  |
| 3  | sysctl (13)          | 0.0.0.0/0            | True  | True  |
| 4  | sysctl (13)          | ::/0                 | True  | True  |
| 5  | nuc-docker01 (1)     | 192.168.1.14/32      | True  | True  |
| 6  | nuc-docker01 (1)     | ::/0                 | True  | True  |
| 7  | nuc-docker01 (1)     | 192.168.1.0/24       | True  | False |
| 8  | nuc-docker01 (1)     | 192.168.1.13/32      | True  | True  |
| 9  | japan-rpi4 (50)      | 0.0.0.0/0            | True  | True  |
| 10 | japan-rpi4 (50)      | ::/0                 | True  | True  |
| 11 | quitman-rpi4 (49)    | 0.0.0.0/0            | True  | True  |
| 12 | quitman-rpi4 (49)    | ::/0                 | True  | True  |
| 13 | quitman-rpi4 (49)    | 192.168.1.0/24       | True  | False |
| 14 | quitman-rpi4 (49)    | 192.168.68.0/24      | True  | True  |
| 15 | piaware-rpi4 (46)    | 0.0.0.0/0            | True  | True  |
| 16 | piaware-rpi4 (46)    | ::/0                 | True  | True  |
| 17 |  (0)                 | 0.0.0.0/0            | False | False |
| 18 |  (0)                 | ::/0                 | False | False |
| 19 |  (0)                 | 0.0.0.0/0            | True  | True  |
| 20 |  (0)                 | ::/0                 | True  | True  |
| 21 |  (0)                 | 0.0.0.0/0            | True  | False |
| 22 |  (0)                 | ::/0                 | True  | False |
|----|----------------------|----------------------|-------|-------|

I don't know why there are blank routes. Previously deleted machines still have active routes?

@iFargle
Copy link
Owner Author

iFargle commented Mar 3, 2023

lol, using Headscales CLI confirms this:

[root@sysctl ~]# de headscale headscale  routes list
ID | Machine      | Prefix          | Advertised | Enabled | Primary
1  | nuc-docker01 | 0.0.0.0/0       | true       | true    | -
2  | sysctl       | 10.2.0.0/24     | true       | true    | true
3  | sysctl       | 0.0.0.0/0       | true       | true    | -
4  | sysctl       | ::/0            | true       | true    | -
5  | nuc-docker01 | 192.168.1.14/32 | true       | true    | true
6  | nuc-docker01 | ::/0            | true       | true    | -
7  | nuc-docker01 | 192.168.1.0/24  | true       | false   | false
8  | nuc-docker01 | 192.168.1.13/32 | true       | true    | true
9  | japan-rpi4   | 0.0.0.0/0       | true       | true    | -
10 | japan-rpi4   | ::/0            | true       | true    | -
11 | quitman-rpi4 | 0.0.0.0/0       | true       | true    | -
12 | quitman-rpi4 | ::/0            | true       | true    | -
13 | quitman-rpi4 | 192.168.1.0/24  | true       | false   | false
14 | quitman-rpi4 | 192.168.68.0/24 | true       | true    | true
15 | piaware-rpi4 | 0.0.0.0/0       | true       | true    | -
16 | piaware-rpi4 | ::/0            | true       | true    | -
17 |              | 0.0.0.0/0       | false      | false   | -
18 |              | ::/0            | false      | false   | -
19 |              | 0.0.0.0/0       | true       | true    | -
20 |              | ::/0            | true       | true    | -
21 |              | 0.0.0.0/0       | true       | false   | -
22 |              | ::/0            | true       | false   | -

@iFargle
Copy link
Owner Author

iFargle commented Mar 3, 2023

juanfont/headscale#1228

@iFargle iFargle closed this as completed in 73ecdff Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant