Announcement

Collapse
No announcement yet.

Mini Webserver questions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mini Webserver questions

    A few years ago I released an app that actually was a huge hit with BBS users - an app to put in place of a BBS to send a message that the BBS was down, try ag ain later.

    I've had a need for this same app on the web now, and while there may be one out there it would be great to have a re-release of BBSDown!

    So I grabbed the echo server sample and got it working, using a file on the local hard drive - all's well.

    But now I'd like to capture some things from the user, such as their IP address specifically.......how does one grab that?

    I don't care what browser they use, or settings or anything else - mainly for security reasons.


    Looking at the sample for PBWin 8.04 - how would the echo SERVER grab the clients IP address based on teh TCP connection?

    I could just be tired, maybe this is easy......?

    Thanks,
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    This is the code I use for pulling the remote user's IP address with just the TCP socket handle. This code has worked fine from within my compiled CGI's (written with PowerBASIC) for quite a long time.

    I have no proprietary interest in this code. Anybody may use it as they wish.

    Code:
    #include "w32_s2.inc" 'might be wrong INC name - I actually use a custom INC file created by one fo the forum members
    
    'make sure you first invoke WSAStartup() to get the winsock fired up
    
    FUNCTION RemoteIp (BYVAL ntcp AS DWORD) EXPORT AS LONG
        LOCAL L AS LONG, L1 AS LONG
        LOCAL sa AS sockaddr_in
        L1 = LEN(sa)
            IF getpeername(ntcp, sa, L1) = 0 THEN
                L = sa.sin_addr.s_addr
                FUNCTION = L
            END IF
    END FUNCTION

    Comment


    • #3
      Thanks Clay -

      Also forgot about the header file, the browser sends the HOST param..
      Here's my logfile, shows the host (Was used for debug but now part of the app)

      #Software: BBSDown! v3.0
      #Date: 2008-09-27 14:38:02
      #Fields: date time s-ip s-port cs-username c-ip cs(User-Agent) sc-bytes cs-bytes time-taken
      2008-09-27 14:38:07: - 0
      2008-09-27 14:38:07: - GET / HTTP/1.1
      Accept: */*
      Accept-Language: en-us
      UA-CPU: x86
      Accept-Encoding: gzip, deflate
      User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)
      Host: tngxp
      Connection: Keep-Alive


      PS - I race bathtubs for the American Legion, post 149 here in Bremerton

      Saw your link to your AL website
      Last edited by Scott Turchin; 27 Sep 2008, 10:38 AM.
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Race bathtubs? Maybe if I were 20 years younger, I'd consider it. hehehe

        Nah, seriously, I'm only 47-yrs-old, but after 2-1/2 decades of smoking cigars and letting my body go to hell, racing bathtubs would definitely be a recipe for a heartattack.

        Although, to be fair to myself, I quit tobacco 9-10 days ago, all of it ('sides cigars, I was also smoking cigarettes and chewing snuff). To keep the story short, I have to stay quit for another 20 days in order to honor my word of honor that I gave to a young man about quitting. Now, if I start up again 20 days from now, I'll be a perfect fool. Anyway, once I am fairly confident that I have the tobacco addiction under control, I am going to begin an exercise regimen. So, time will tell.

        Comment


        • #5
          I'm only 42, need to quit the tobacco myself but I work out 2-3 times a week in Shotokan Karate, race bathtubs in summer and whatever else in winter!

          Here's my app, just need to put some details and user editable options in and get a new release after almost 12 years since the last release

          http://www.tngbbs.com:8080/
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


          • #6
            am I missing something?
            why not just use something like
            Code:
            ipAddr$= ENVIRON$("REMOTE_HOST")

            Comment


            • #7
              Mainly b/c it's PBWin and I want to just pull it from the header packet - it's there already...

              I figured it out though, seems on the local network it will user hte username but over the net an IP comes across...
              Two step parsing...

              Scott Turchin
              MCSE, MCP+I
              http://www.tngbbs.com
              ----------------------
              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

              Comment

              Working...
              X