[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 577
  • Last Modified:

Terminating a Dial Up RAS Connection

Creating a DialUp client, working with VB6 using both Microsoft RAS and a RAS control by Catalyst.com, there are some situations when my program crashes leaving the user STUCK online. I need to be able to be 100% certain that the line will be CUT whenever this occurs but HOW ? Can obtain PID for Catalyst RAS control, but how to kill it ? Have built 'partner program' using heartbeat methodology to monitor main Dial Up Client BUT unable to discover how to kill the process. Any ideas please ?
0
snoopy2000
Asked:
snoopy2000
  • 6
  • 5
1 Solution
 
snoopy2000Author Commented:
Catalyst.com RAS control has 'Auto Disconnect' option BUT this does not always work if the calling program fails, problem is one of security since a hacker of our system may deliberately crash the client in order to stay online and bypass our time recording system. We are a UK ISP and getting the security aspects 100% right is crucial to our business survival.

Any ideas or related suggestions would be really welcome and rewarded, thanks.
0
 
jhanceCommented:
If you use the Windows RAS API function RasEnumConnections and enumerate all the connections and then call RasHangUp on each of them, you will get all the connections cleared from a "Windows" point of view.
0
 
snoopy2000Author Commented:
Hi thanks - we tried that BUT if the program crashes then the line is left connected. Perhaps my 'partner program' can do the same sequence if the main program crahses ? However what seesm to be going on is that Windblows looses track of the connection, think it is closed BUT it is not ... any ideas ?

Perhaps I should explain that our application is deliberately targeted by Hackers & Freeloaders seeking Totally FREE Internet Access - ie. not even call charges - here in the UK we have various schemes offering 0800 dialup on a points basis against prepaid or credited points - UK local calls are not 'free' as in the USA, so call charges and ways to minimize them are a big issue over here.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
jhanceCommented:
I know that the RasHangUp will close dial-up connections left open by a crashed or hung application.  When I'm debugging an application that uses RasDial, I always have a small app handy that just enumerates all the DUN sessions and calls RasHangUp on all of them.  This fixes the problem where the original connection handle is lost but Windows still think the connection is open and won't allow a new one.

I suppose there could be an intermediate state where the line is hung but Windows RAS API thinks the connection is closed.  I'm certain in such a situation that the only solution would be to reboot Windows.  I've not seen this happen, however, and I've developed many RAS based apps.

Perhaps in your situation a "keep-alive" type of service could be used.  It would keep tabs on the catalyst.com based connection application and if it fails to get a response evey X seconds, it would terminate everything and start things up clean.  In this case, BOTH the monitoring program and the dial-up application would have to crash for the system to be left online.
0
 
jhanceCommented:
Just another thought.  

Since _YOU_ are the ISP, would it make more sense to built the security into the server side of the connection rather than the client side?  Since you really have little control over what people do to programs running on their systems isn't there something you can do on the server side to police activities and thwart hackers?
0
 
snoopy2000Author Commented:
Yes and No - we do have security on the Server Side, however that does not make it impossible for somebody to Hack our servers, we have already been hacked despite all the usual precautions - also the physical call goes via another company, a Telco, who operate the physcial Racks & Switches, they do not have good security since they are actually eager to keep people Online {since that normally generates Profit for them} the UK system is in flux & turmoil, nobody {Not even our National Carrier} has a reliable 'Credit' measuring system for Internet users.

We would have to physcially control the Racks to be able to Force Disconnect a 'bad' user, or one whose credit has expired, hence we have gone down the 'Special Software DialUp' route .. our company will become a Telco in about 8 weeks, then have all the equipment on our premeses, but meanwhile around $100,000 of 'Prepaid or Credit style' calls will pass through and could very easily be abused.

Life a'int easy  ;o}

0
 
snoopy2000Author Commented:
Sorry, I saw your postscrupt before your previous answer ... we have tried the RAS Hangup route but to no avail, forcefully rebooting our users PC's would not make us very popular ... our Heartbeat {keep alive} program does monitor every second, and attempt to force the client closed, and the line closed, if there is a problem ... however simply freezing them would still allow a hacker to stay online ... really we are in a no-win situation until we fully control the racks ... however I have to keep trying ... is your 'small app enumerator' available ? thought I think that Windows does often get confused and believing itslef to be infallible simply ignores requests it considers irrelevant ... we are also looking at forcing shut all comm ports to kill of modem connections so they time out ... however we are not so expert hence the plea for help ... many thanks
0
 
jhanceCommented:
What problem are you seeing with the RasHangUp method?  I've found it to be reliable.

Here is the code I use:

void CloseAllConnections()
{
      HRASCONN hrc;

      DWORD dwBufSize, dwNumConnections;

      LPRASCONN plpRasConn;
      plpRasConn = new RASCONN[32];

      plpRasConn[0].dwSize = sizeof(RASCONN);
      dwBufSize = 32 * sizeof(RASCONN);

      if(RasEnumConnections(plpRasConn, &dwBufSize, &dwNumConnections) != 0){
            AfxMessageBox("ERROR", MB_OK);
      }

      for(DWORD i=0; i<dwNumConnections; i++){
            hrc = plpRasConn[i].hrasconn;
            RasHangUp(hrc);
            ::Sleep(1000);
      }

      delete [] plpRasConn;
}
0
 
snoopy2000Author Commented:
Many thanks for your code fragment which I have added to a sample test program and found to be VERY reliable. We have been working in VB rather than C++, however that is because we inherited the partially developed program from another group who have since left this company. We are gradually converting over to Borland C++ which is my favourite but there is so little time and so much to do.

Once again THANKS, your method certainly seems superior to anything we have used before.
0
 
snoopy2000Author Commented:
Your help has saved us a great deal of anguish and frustration, this has been a probeloem we have tried to overcome for almost two weeks. It is a great pleasure to 'cyber meet' a real Expert. Thanks once again for your help.
0
 
jhanceCommented:
Glad to be of assistance.  BTW, I don't see any reason why the above code would work as well in VB as it does in C++...

Of course, it's my opinion that for most system programming tasks, C++ and in particular Visual C++ is a better environment than VB.  When I see the gyrations that need to take place to call into a Windows DLL (like RASAPI32.DLL) from VB, I know that it's still not ready for this kind of work.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now