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

Do you know something about TUN method? #801

Closed
rain2fog opened this issue Oct 28, 2020 · 11 comments · May be fixed by #1048
Closed

Do you know something about TUN method? #801

rain2fog opened this issue Oct 28, 2020 · 11 comments · May be fixed by #1048

Comments

@rain2fog
Copy link

Hi Adrien Vergé
It's amazing when I first time found your project. Thank you for giving this open source project so much ....
I analyzed the http request about "/remote/fortisslvpn_xml ". I found vpn server side would response a special xml content which contain two entry tunnel-method. The first item is ppp. The secound item is tun. You chose ppp as the local net forwarding solution.
Do you have any clues about tun as the local net forwarding solution?

@adrienverge
Copy link
Owner

Hello Hang Zhou, I have no clue about the tun entry. Maybe it's usable to set up a connection, but I guess it's dependent on the Fortinet appliance version.

@DimitriPapadopoulos
Copy link
Collaborator

DimitriPapadopoulos commented Oct 28, 2020

@rain2fog Also just wondering how portable would the tun entry be on macOS? Can you shed some light on the subject?

@rain2fog
Copy link
Author

we simulated the PPP negotiation procedure. There are 3 stages in PPP protocal.
The 1th stage is LCP. client will send Magic-Number and MRU request to fortivpn server, then will ack the server request. server will send the Magic-Number and ack the client request.
The 2th stage is IPCP. both will will send the IPCP config-request to other. client need to send the IPCP config-request Option (3) with the IP which come from the XML. then both config-request need to be ack.
The 3th stage is 0x0021. we can read and write IP packet from tun NIC. then sending data by encapsulating or decapsulating the IP packet with header 0x0021(2 Bytes) + (totolsize(2 Bytes) + 0x5050 + pppsize(2 Bytes)).
we also need send the LCP echo-request to fortinet VPN to keep the TCP connection wouldn't close.

@DimitriPapadopoulos
Copy link
Collaborator

@rain2fog We spawn pppd because when openfortivpn had been written no PPP libraries were available at the time. Nowadays GPL-compatible PPP code is available: #650 (comment). Do you mean we could use TUN and such PPP code instead of spawning pppd? I'm not sure what we should do with the above information. Do you plan on providing a patch?

@rain2fog
Copy link
Author

rain2fog commented Dec 8, 2020

@DimitriPapadopoulos you are right. This is the patch for demo. tun.patch

@DimitriPapadopoulos
Copy link
Collaborator

@rain2fog Impressive work! I'll try to test it soon. Would you agree to open a pull request to discuss the patch?

Also how would you feel about using existing PPP code to ease maintenance or even help convergence between projects? For example see - by order of preference:

On the other hand the PPP implementation is rather short.

@rain2fog
Copy link
Author

rain2fog commented Dec 8, 2020

The progress is very easy. you can read the RFC1661 and RFC1332 to get the detail protocol design. this C patch came from my co-worker not me.

@DimitriPapadopoulos
Copy link
Collaborator

Would your coworker want to create a pull request? The idea is that her/his contribution are properly recognised. Plus we can discuss implementation details.

DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Dec 8, 2020
pppd → tun interface + embedded PPP code
@DimitriPapadopoulos
Copy link
Collaborator

Just a reminder for myself. This should help handle both these methods proposed in the XML configuration sent by Fortigate appliances:
<tunnel-method value='ppp' /><tunnel-method value='tun' />

DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Dec 18, 2020
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Dec 18, 2020
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Dec 18, 2020
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Dec 18, 2020
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Feb 19, 2021
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Dec 10, 2022
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue Dec 10, 2022
pppd → tun interface + embedded PPP code
@DimitriPapadopoulos
Copy link
Collaborator

DimitriPapadopoulos commented Dec 10, 2022

@rain2fog I have been maintaining your patch in my tun branch:
https://github.com/adrienverge/openfortivpn/tree/tun

I can see a couple CodeQL alerts in your code:

Also complier warnings:

In function ‘conf_option_encode’,
    inlined from ‘conf_request’ at src/io.c:415:2:
src/io.c:337:16: warning: ‘request.tail’ may be used uninitialized [-Wmaybe-uninitialized]
  337 |         optlist->tail->type = type;
      |         ~~~~~~~^~~~~~
src/io.c: In function ‘conf_request’:
src/io.c:410:33: note: ‘request’ declared here
  410 |         struct conf_option_list request;
      |                                 ^~~~~~~
In function ‘conf_option_encode’,
    inlined from ‘ipcp_packet’ at src/io.c:984:4:
src/io.c:337:16: warning: ‘request.tail’ may be used uninitialized [-Wmaybe-uninitialized]
  337 |         optlist->tail->type = type;
      |         ~~~~~~~^~~~~~
src/io.c: In function ‘ipcp_packet’:
src/io.c:981:49: note: ‘request’ declared here
  981 |                         struct conf_option_list request;
      |                                                 ^~~~~~~
In function ‘conf_option_encode’,
    inlined from ‘ipcp_packet’ at src/io.c:1038:4:
src/io.c:337:16: warning: ‘request.tail’ may be used uninitialized [-Wmaybe-uninitialized]
  337 |         optlist->tail->type = type;
      |         ~~~~~~~^~~~~~
src/io.c: In function ‘ipcp_packet’:
src/io.c:1035:49: note: ‘request’ declared here
 1035 |                         struct conf_option_list request;
      |                                                 ^~~~~~~

DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue May 4, 2023
DimitriPapadopoulos added a commit to DimitriPapadopoulos/openfortivpn that referenced this issue May 4, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue May 4, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue May 6, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue May 7, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue May 7, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue May 8, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Jun 21, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Sep 25, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Nov 5, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Nov 6, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Nov 6, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Nov 8, 2023
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Mar 3, 2024
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Mar 4, 2024
pppd → tun interface + embedded PPP code
DimitriPapadopoulos added a commit that referenced this issue Apr 22, 2024
pppd → tun interface + embedded PPP code
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

Successfully merging a pull request may close this issue.

3 participants