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

Show when link has dropped? #10

Open
AndyW999 opened this issue Jun 5, 2023 · 6 comments
Open

Show when link has dropped? #10

AndyW999 opened this issue Jun 5, 2023 · 6 comments

Comments

@AndyW999
Copy link

AndyW999 commented Jun 5, 2023

If you deactivate the server or the server endpoint is removed from the network is there a way of indicating this?

It works great on my STM32F407 and ESP32 with ciniml/WireGuard-ESP32-Arduino

Thanks

Andy.

@fspiot
Copy link

fspiot commented Apr 10, 2024

Hello! Do you use FreeRTOS+LWIP to implement Wireguard on STM32F407? Can you share your project?

@AndyW999
Copy link
Author

Sorry I do not use an RTOS, I prefer being in control of my code ;)

@fspiot
Copy link

fspiot commented Apr 10, 2024

Sorry I do not use an RTOS, I prefer being in control of my code ;)

thanks!
Can you really realize it using STM32F407?
I compiled it according to the demo provided by the author. But
wg_netif = netif_add(&wg_netif_struct, &ipaddr, &netmask, &gateway, &wg, &wireguardif_init, &ip_input);
There seems to be a problem with this function. Do you know what's going on here?

@AndyW999
Copy link
Author

Set it up and my WG implementation is in the attached ZIP file, hope it is of some use!

I also got it working with ESP32

static void wireguard_setup()
{
struct wireguardif_init_data wg;
struct wireguardif_peer peer;
ip_addr_t ipaddr = IPADDR4_INIT_BYTES(WIREGUARD_IPADDRESS[0], WIREGUARD_IPADDRESS[1], WIREGUARD_IPADDRESS[2], WIREGUARD_IPADDRESS[3]);
ip_addr_t netmask = IPADDR4_INIT_BYTES(WIREGUARD_SUBNET[0], WIREGUARD_SUBNET[1], WIREGUARD_SUBNET[2], WIREGUARD_SUBNET[3]);
ip_addr_t gateway = IPADDR4_INIT_BYTES(WIREGUARD_GW[0], WIREGUARD_GW[1], WIREGUARD_GW[2], WIREGUARD_GW[3]);

// Setup the WireGuard device structure
wg.private_key = &WIREGUARD_MY_PRIV;
wg.listen_port = WIREGUARD_LISTENPORT;
wg.bind_netif = NULL;

// Register the new WireGuard network interface with lwIP
wg_netif = netif_add(&wg_netif_struct, &ipaddr, &netmask, &gateway, &wg, &wireguardif_init, &ip_input);

// Mark the interface as administratively up, link up flag is set automatically when peer connects
netif_set_up(wg_netif);

// Initialise the first WireGuard peer structure
wireguardif_peer_init(&peer);
peer.public_key = &WIREGUARD_THEIR_PUB;
peer.preshared_key = NULL;
// Allow all IPs through tunnel
IP4_ADDR(&peer.allowed_ip, 0, 0, 0, 0);

// peer.allowed_ip = IPADDR4_INIT_BYTES(0, 0, 0, 0);
IP4_ADDR(&peer.allowed_mask, 0, 0, 0, 0);
// peer.allowed_mask = IPADDR4_INIT_BYTES(0, 0, 0, 0);

// If we know the endpoint's address can add here
IP4_ADDR(&peer.endpoint_ip, WIREGUARD_ENDPOINTIP[0], WIREGUARD_ENDPOINTIP[1], WIREGUARD_ENDPOINTIP[2], WIREGUARD_ENDPOINTIP[3]);

// peer.endpoint_ip = IPADDR4_INIT_BYTES(10, 0, 0, 12);
peer.endport_port = WIREGUARD_LISTENPORT;//51820;

// Register the new WireGuard peer with the netwok interface
wireguardif_add_peer(wg_netif, &peer, &wireguard_peer_index);

if ((wireguard_peer_index != WIREGUARDIF_INVALID_INDEX) && !ip_addr_isany(&peer.endpoint_ip)) {
	// Start outbound connection to peer
	wireguardif_connect(wg_netif, wireguard_peer_index);
}

}
Wireguard.zip

@AndyW999
Copy link
Author

Looks like the paste got a bit screwed!

WGSetup.txt

@AndyW999 AndyW999 reopened this Apr 10, 2024
@fspiot
Copy link

fspiot commented Apr 10, 2024

Looks like the paste got a bit screwed!

WGSetup.txt
Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants