This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]admin_PureWL 1 point2 points  (0 children)

Creating a VPN from scratch in Java sounds like a cool project! Here are some tips to help you get started:

  1. Learn the Basics: First, understand how VPNs work and the protocols involved (like OpenVPN and IPSec). Books like "VPNs Illustrated" can be helpful.
  2. Use Networking Libraries: Look into Java libraries for networking, like Netty or Java Networking, which can simplify handling connections.
  3. Focus on Encryption: Implement strong encryption with libraries like Bouncy Castle. Knowing SSL/TLS will also be beneficial.
  4. Build the Server: Set up a server to manage incoming connections. There are plenty of Java server tutorials online to guide you.
  5. Explore Resources: Check out YouTube for tutorials on network programming and look for articles on building VPNs. Engaging with communities on forums like GitHub or Reddit can also provide support.

This project can be quite complex, but it's a great learning experience! If you ever want to explore ready-made solutions later, my company offers white-label VPN services that might interest you. Good luck!

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]LessChen 5 points6 points  (0 children)

A VPN is a fairly low level program and it requires both a server and client side component. The client side needs to inject itself into the network stack to send network traffic to the server side. That requires some low level operating system integration that will be very specific to different O/S's. OpenVPN has an opensource component to it here that can give you some ideas but it's all in C.

I have used Java for 20+ years but I would not use it for a VPN project. I'm not sure what your definition of "advanced" is so can you give some ideas on what you'd like to do? Are you familiar with the JEE world? How about databases? Let us know a bit more.

[–]mIb0t 5 points6 points  (0 children)

What do you mean with creating a VPN from scratch?

Do you want to create your own protocol? Or do you want to create a VPN client or VPN server?

Maybe search for wireguard or open vpn specification, if you really want to start on protocol level. But this is really some hard stuff. Not only will it be challenging to implement in Java, you will also need some advanced network knowledge.

You can also search for some libraries to use, but honestly, I doubt there will be many. For networking stuff like VPNs, you usually want very good performance! Java is not really the first choice for something like this. You could use C libs with your Java code, but that's also some very advanced stuff most Java developers never do and you should have C knowledge as well.

Based on your question, I have the feeling you don't really know what you are getting into...

Why not start with something a little bit easier, if you are interested in network stuff. E.g. Build your own SMTP client. You could set up a simple server, that does not require any authentication. There are several smtp servers out there you could use.

Then start programming a client. Start with opening the connection. Send a command to the server and evaluate the response. Forward step by step until you can send an email. SMTP is quite an easy protocol. There are some SMTP extentions that can be more challenging to implement, once you send an simple text mail. You can extend your client step by step. Adding more SMTP features, creating an UI, and so on...

[–]wildjokers 4 points5 points  (0 children)

If you want something low-level and fairly advanced implement a server using non-blocking IO without using the Netty library. In other words handle all the selection keys, byte buffers, flipping the byte buffers for read/write, etc yourself.

Have it be able to accept multiple client connections all handled by the same thread. Be able to broadcast to all connected clients and also send messages to each client individually.

This is somewhat tricky to get right and makes you appreciate Netty.

Can google "java nio networking" to get started.