Extended support for 2010 dxf format

Today, I added the ezdxf library inside our text_to_dxf project. Now, our project is able to generate a R2010 format dxf drawing. I have implemented the line, circle and arc entities using this library. Here’s the commit.

Advertisements

Day 4 Week 4

It was not a productive day at all. I skiped my gate preparation because I woke up late. I also skiped my morning meal.

I reached TCC by 9:30 AM and started replying to mails. I got a question from Mr. HS Rai asking about the comparison between ezdxf and libdxfrw. So, I searched for libdxfrw over Internet and then over GD’s mailing list and I got really a lot of threads regarding it. I found that ezdxf makes it a lot easier to use dxf than libdxfrw.

After having lunch by 1 PM, I and Ranvir got stuck in rain for about an hour. Then, on reaching TCC, I started reading all the tutorials about ezdxf and implementing one by one every entity. Then, the worst thing happened, the documentation’s server stopped responding for rest of the day. I got nothing productive today. I hope tomorrow will be a better day.

Day 3 Week 4

Today, I woke up at 3:30 AM and studied about “Longest common subsequence” as a part of my Gate syllabus.

Then, I reached TCC at around 9:15 AM and started working on CAD diff project. I tried different entities as defined by the ezdxf library like line, circle, arc etc. It worked really well with QCAD, LibreCAD and DraftSight. But, I didn’t find any option to define layers. I’ll look into it further. Tomorrow, I’ll try to implement the functions of this library inside the code of our project.

I also learned about Apache server in order to help Amarjeet with reverse proxy related problem.

Day 2 Week 4

Today, I started my day with working on remote controlling through mobile. I was successful in using bvnc with our SSH tunnel for controlling my laptop from my android mobile. I will be sharing the tutorial regarding it soon.

I also helped Harinder in installing the setup for VNC on Mr. HS Rai’s computer and then automating it. From yesterday I’ll start back my CAD related tasks.

Starting SSH tunnel on Windows Start

In my last blog, I talked about controlling a computer from another computer without taking any tension about the OS which is running on them. If you haven’t read it already, here is the link. Today, I want to talk about automating this process. So, let’s get directly into it.

TightVNC already provides the options for starting it as a service in windows. If you want to know the procedure, here is the link to its guide. I will provide in here the steps to setup the SSH tunnel which will start as soon as the windows start and will also restart itself when the network disconnection occurs for some time. We will be using the batch script for our purpose and here is the actual script which we will be using:

:: This is a batch file. Save with file name: plink_forever.bat
 :restart
 plink VNC_SSH -pw XXXXX
 goto restart

Here, “::” specifies the comment, “:restart” is the label, plink is the command line tool for putty, VNC_SSH is the session which we stored during setting up our ssh tunnel in PuTTy, “-pw XXXX” specifies the password of the ssh account, and “goto restart” is the jumping statement which says to go to the label “restart” and start executing statements from there.

So, here are the steps:

  1. Copy the above-given content inside a new text file, change the password XXXX to your ssh account password and save the filename as “plink_forever.bat”.
  2. Right click and cut this file.
  3. Go to start, search “run”, press enter, type inside run box “shell:startup”, press enter, a folder opens up, paste the file inside it and you’re done.

From now on, whenever the windows start, this file will automatically start plink ssh tunnel. A new command line interface will open up but don’t close it, as it will stop this service, just keep it minimised.

One more thing that you have to do is to make sure that Windows doesn’t go to sleep when not in use. You can do this by following below steps:

  1. Go to control panel > power options > change plan settings (of selected plan).
  2. Select never in “put the computer to sleep” option

P.S: I know the way I have used the password is a very insecure method. I will update this post as soon as I’ll learn about Pageant which will save the SSH key for us in an encrypted manner.

How to remotely control your computer behind NAT router and Firewall

Hello, fellow readers!

Today, I am going to share a way to access a computer behind NAT Router and Firewall. There are literally several ways to access the computer whose working totally depends upon your case. I am considering the case when both client (controller) and host (controlee) are from different networks and are behind NAT Router and firewalls.

vncthroughfirewalldiagram3

We are going to use a third party server which has an ssh server running all the time. But before going directly into the steps, I want to share conceptually what we are going to do. If you just want the how part, you can skip the theory part.

Theory

Firewalls usually block every incoming connection from outside the network except the ones whose ports are open (check your blocked ports, http://canyouseeme.org). But if the connection is requested from inside the network, Firewalls will allow most of the connection (assuming advanced packet filtering is not applied). To check which outgoing ports are allowed by your network, visit http://portquiz.net.

figure_7-1

So, we have to start a connection from inside the network and that’s where we need a third party server (packet relay server or TCP relay server) which has a public IP. The packet relay server will act as a bridge between client and host which passes every data coming from client to host. We will first request an SSH connection from both client and host to the server. This will let the firewalls to pass the connections on both sides (assuming both firewalls allow Port 22 in outgoing rules) and will make a tunnel between client-server and server-host. Most firewalls cannot look inside these tunnels and thus cannot block the content being passed through them. Then, we will pass the VNC data from client to server and from server to host on port 5900 which firewall cannot see as it is happening inside the tunnel.

VNC through SSH tunneling (2)

 

Instead of assuming port 5900 is free on the SSH machine, we will assume both users agreed to use 5933. This will illustrate how to use a different port for the redirection. It could be any port, what matters is that both parties refer to the same one.

To make an ssh tunnel from client (VNC Viewer) to server, we will use

ssh -t -L 5900:localhost:5933 user@third-machine.net

Here, the command means: connect with ssh to user@third-machine.net, and forward all connection attempts to the local 5900 to port 5933 on the machine called localhost, which can be reached from the third-machine.net machine.

To make an ssh tunnel from host (VNC server) to server, we will use

ssh -t -R 5933:localhost:5900 user@third-machine.net

Here, the command means: connect with ssh to user@third-machine.net, and forward all connection attempts to the remote 5933 to port 5900 on the machine called localhost, which can be reached from your local machine. This is called reverse ssh tunnel.

After this successful setup, run VNC server at host listening to localhost on port 5900. Then, run VNC viewer at client looking at localhost on port 5900. Tadaa! now you can control the host’s screen. Now let’s see how to do it actually.

Procedure

Setting up VNC server on Ubuntu

We will be going to use x11vnc for our purpose because it makes all the settings very simple for Unix-like systems.

Step 1: Install x11vnc using sudo apt install x11vnc.

Step 2: Run command: x11vnc -ssh username@third-machine.net:33. And you are done with the reverse ssh command and VNC server starts listening to localhost on port 5900. You can also set a password for your VNC server by using -passwd XXXX with the above command. Add -forever to run it forever even when the ssh connection is lost and -shared to share the screen with more than one person. Look for other options with the man command.

Setting up VNC server on Windows

We will be going to use PuTTY for establishing ssh tunnel and TightVNC as a VNC server.

1. Establishing SSH connection

Download PuTTy from here and install it using default settings. Open putty by typing it in command prompt and follow the steps as described below:

pnd8cjp

Step 1: Add a name to this session.
Step 2: Enter host name “username@host_ip”and port 22.
Step 3: Click on plus sign before SSH.
x55mbgy
Step 4: Click on tunnels.
Step 5: Enter source port= 5933, destination= localhost:5900, select remote and auto and click Add.
Step 6: Click on X11.
vaaumsr
Step 7: Check enable x11 forwarding.
Step 8: Click on session.
jioizj3
Step 9: Click Save. Now whenever you will open putty, just click on this saved session and then load.
Step 10: Click Open. The ssh session will start. Enter the password, if asked.

2. Starting VNC server

Download TightVNC from here and install it using default settings. Open up TightVNC server. An icon “V” appears at the bottom right corner, right click on that icon, go to configuration and make the settings as per below given images:
sxv0ijx
ojacexp
Set the primary password and then press OK. Now, we are done with setting up VNC server.

Starting VNC Viewer

We will be using SSVNC software as a VNC Viewer on the client’s computer. It comes for many platforms. Ubuntu users can download using command: sudo apt install ssvnc. Others can download it from here.

Start ssvnc and then:
– select “Use ssh”.
– enter username@third-machine.net:33 in “VNC Host:Display” entry box and enter the password for VNC server in the “VNC Password” entry box.
– click on connect.
– enter the password for your ssh account if asked.

Congratulations!! You have successfully connected your computer to the host’s computer. Use F9 to see other’s screen in full-screen mode.

Happy Remote Controlling!! 😉

P.S: Here are some links which were really helpful in reaching out to this solution:

http://www.karlrunge.com/x11vnc/faq.html#faq-firewall-out

http://lightofdawn.org/wiki/wiki.cgi/Nat2NatVNC