aspose file tools*
The moose likes Java in General and the fly likes how to know that a particular ip is being accessed. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to know that a particular ip is being accessed." Watch "how to know that a particular ip is being accessed." New topic
Author

how to know that a particular ip is being accessed.

kamal krishna bhatt
Ranch Hand

Joined: Apr 26, 2011
Posts: 41

i want to write an application which is running on a gateway and detect whether there is an access request for a particular ip address over any protocol.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

That's nice. So how are things going along with that?

OK, now seriously, do you have a question? Because I just read a notification that you are going to write a program.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
kamal krishna bhatt
Ranch Hand

Joined: Apr 26, 2011
Posts: 41

yes, i want to know which API to use ,currently i am having a servlet which is listening to a particular url to be hit and then do whatever needed,but it is listening for http requests only if some body do ssh on that server then what should i do?
is there any other way of detection?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

To listen for SSH requests without creating a server socket on the SSH port (which you can't because there's already the SSH server running on it), you will probably need to interact with the network interface on a low level. Pure Java can't do that, so you'll either have to use JNI to write something yourself or use a third party library that has already implemented this. I think jpcap is a suitable library, but I haven't tested it myself.
kamal krishna bhatt
Ranch Hand

Joined: Apr 26, 2011
Posts: 41

Thank you !
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

You're welcome.
kamal krishna bhatt
Ranch Hand

Joined: Apr 26, 2011
Posts: 41

ya that is true i cant create a socket on 22 port as ssh already running on that port but isn't it possible to redirect ssh request to another port where i can create socket process it here and the redirect it back to port22 ?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

You could write your own raw proxy. In short:
- create a ServerSocket on port 22
- upon an incoming connection, create a Socket to the SSH server (on a different port)
- copy all data from the incoming Socket to the SSH Socket and vice versa
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to know that a particular ip is being accessed.