[jira] [Commented] (DIRMINA-963) Socks5 and ProxyConnector don't work with InetSocketAddress.createUnresolved

2024-02-08 Thread Jonathan Valliere (Jira)


[ 
https://issues.apache.org/jira/browse/DIRMINA-963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17815906#comment-17815906
 ] 

Jonathan Valliere commented on DIRMINA-963:
---

I can try to look at this sometime in the next couple of weeks.  However, it 
clearly looks like this isn't a problem for many people given how old this 
ticket is.

> Socks5 and ProxyConnector don't work with InetSocketAddress.createUnresolved
> 
>
> Key: DIRMINA-963
> URL: https://issues.apache.org/jira/browse/DIRMINA-963
> Project: MINA
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.0.7
>Reporter: Daniele guiducci
>Assignee: Jonathan Valliere
>Priority: Major
>  Labels: InetSocketAddress, bug, proxy, socks
>
> I'm tring to use Tor to connect using proxy (SOCKS5).
> InetSocketAddress resolve dns without use Tor, so i can not use in production.
> To use tor to resolve dns i must use   InetSocketAddress.createUnresolved.
> java.net.Socket work perfectly also with .onion url.
> {code}
>  public static void main(String[] args) throws Exception{
> NioSocketConnector nioConnector=new NioSocketConnector();
> nioConnector.setConnectTimeoutMillis(6);
> SocksProxyRequest pr = new SocksProxyRequest(
> SocksProxyConstants.SOCKS_VERSION_5,
> SocksProxyConstants.ESTABLISH_TCPIP_STREAM,
> new InetSocketAddress("www.google.com", 80), ""); 
> ProxyIoSession ps=new ProxyIoSession(new 
> InetSocketAddress("127.0.0.1", 9050), pr);
> ProxyConnector connector=new ProxyConnector(nioConnector);
> connector.getFilterChain().addLast("logger", new LoggingFilter());
> connector.setProxyIoSession(ps);
> connector.setHandler(new MyHandler());
> ConnectFuture cf=connector.connect();
> IoSession session=cf.getSession();
> session.getCloseFuture().awaitUninterruptibly();
> cf.awaitUninterruptibly();
>Thread.sleep(4);
> }
> private static class MyHandler extends AbstractProxyIoHandler {
> @Override
> public void proxySessionOpened(IoSession session) {
> System.out.println("ProxySession aperta");
> session.write(IoBuffer.wrap("GET / HTTP/1.0\n\n".getBytes()));
> }
> @Override
> public void  messageReceived(IoSession session, Object msg) {
> System.out.println("Data:"+new String(((IoBuffer)msg).array()));
> }
> @Override
> public void exceptionCaught(IoSession session, Throwable cause)   
> throws Exception {
> System.out.println("Error: "+cause);
> }
> }
> {code}
> ===
> {code}
>   public static void main(String[] args) throws Exception{
> NioSocketConnector nioConnector=new NioSocketConnector();
> nioConnector.setConnectTimeoutMillis(6);
> SocksProxyRequest pr = new SocksProxyRequest(
> SocksProxyConstants.SOCKS_VERSION_5,
> SocksProxyConstants.ESTABLISH_TCPIP_STREAM,
>  InetSocketAddress.createUnresolved("www.google.com", 80), 
> ""); 
> ProxyIoSession ps=new ProxyIoSession(new 
> InetSocketAddress("127.0.0.1", 9050), pr);
> ProxyConnector connector=new ProxyConnector(nioConnector);
> connector.getFilterChain().addLast("logger", new LoggingFilter());
> connector.setProxyIoSession(ps);
> connector.setHandler(new MyHandler());
> ConnectFuture cf=connector.connect();
> IoSession session=cf.getSession();
> session.getCloseFuture().awaitUninterruptibly();
> cf.awaitUninterruptibly();
>Thread.sleep(4);
> }
> private static class MyHandler extends AbstractProxyIoHandler {
> @Override
> public void proxySessionOpened(IoSession session) {
> System.out.println("ProxySession aperta");
> session.write(IoBuffer.wrap("GET / HTTP/1.0\n\n".getBytes()));
> }
> @Override
> public void  messageReceived(IoSession session, Object msg) {
> System.out.println("Data:"+new String(((IoBuffer)msg).array()));
> }
> @Override
> public void exceptionCaught(IoSession session, Throwable cause)   
> throws Exception {
> System.out.println("Error: "+cause);
> }
> }
> {code}
> =
> java.net.Socket example working with tor.
> {code}
> Socket socket=new Socket(new Proxy(Proxy.Type.SOCKS,new 
> InetSocketAddress("127.0.0.1", 9050)));
> System.out.println("Tryng connect ");
> 
> socket.connect(InetSocketAddress.createUnresolved("kpvz7ki2v5agwT35.onion", 

Re: [I] DefaultScpClient.upload(InputStream, ...) will always hit the exit status timeout [mina-sshd]

2024-02-08 Thread via GitHub


TerraNibble commented on issue #427:
URL: https://github.com/apache/mina-sshd/issues/427#issuecomment-1934985712

   This is also easily reproducible using the including unit test 
`ScpTest.testStreamsUploadAndDownload`. Running it you can observe the 5 second 
exit timeout being hit.
   
   Moving the `handleCommandExitStatus` to after the I/O stream 
try-with-resources resolves the timeout but introduces a new race-condition 
with the channels not shutting down gracefully.
   
   I am still not sure why only `upload` is susceptible to this and not 
`runUpload` based on their slightly different use of the `ScpHelper`.
   
   You can simulate the issue by introducing a 200ms delay between the IO 
streams and the channel closing. Hopefully this information is helpful.
   
   ```
   ClientSession session = getClientSession();
   ChannelExec channel = openCommandChannel(session, cmd);
   try {
   try (InputStream invOut = channel.getInvertedOut();
OutputStream invIn = channel.getInvertedIn()) {
   // NOTE: we use a mock file system since we expect no 
invocations for it
   ScpHelper helper = new ScpHelper(session, invOut, invIn, new 
MockFileSystem(remote), opener, listener);
   Path mockPath = new MockPath(remote);
   helper.sendStream(new DefaultScpStreamResolver(name, 
mockPath, perms, time, size, local, cmd),
   options.contains(Option.PreserveAttributes), 
ScpHelper.DEFAULT_SEND_BUFFER_SIZE);
   //handleCommandExitStatus(cmd, channel);
   }
   Thread.sleep(200);
   //handleCommandExitStatus(cmd, channel);
   } catch (InterruptedException e) {
   throw new RuntimeException(e);
   } finally {
   channel.close(false);
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org



Re: [VOTE] Release Mina SSHD 2.12.1

2024-02-08 Thread Guillaume Nodet
Le jeu. 8 févr. 2024 à 03:08, Emmanuel Lécharny  a écrit :
>
> Hi,
>
> built from the distribution:
> - once docker is launched,

Yes, i've been hit by that one more than once.
There's a no-containers-for-windows profile (which is automatically
activated on windows) and which disables
tests that use docker.   I think we should fail fast if this profile
is not enabled and no docker env is available (and maybe rename it as
it would not be windows specific).

> - and Java 11 used
> got it to work.
>
> The README stipulate that Java 8+ is required, the tests are faiking
> with Java 8.

The build time and run time requirements may differ.  The target JDK
is still 1.8.
Fwiw, I've just run a full build of the source release archive with
JDK 8 (docker enabled of course).

> There are a lot of files in sshd-sources and docs that have no AL.2.0
> headers, so rat is failing when ran.

The rat plugin is part of the build, but those files are excluded from
the check.
See https://github.com/apache/mina-sshd/blob/master/pom.xml#L718-L757
I don't think the files in sshd-sources are used in the build, so
maybe we should  get rid of those. They were added as part of
https://issues.apache.org/jira/browse/SSHD-914 4 or 5 years ago but
never touched since...

Guillaume

>
> On 06/02/2024 16:34, Guillaume Nodet wrote:
> > I've staged a candidate release for an SSHD bug fix 2.12.1 release at:
> > Official staging repo:
> >https://dist.apache.org/repos/dist/dev/mina/sshd/2.12.1/
> > Maven staging repo:
> >https://repository.apache.org/content/repositories/orgapachemina-1091
> > Git tag:
> >https://github.com/apache/mina-sshd/commits/sshd-2.12.1
> > Changelog:
> >
> > https://github.com/apache/mina-sshd/blob/sshd-2.12.1/docs/changes/2.12.1.md
> >
> > Please review and vote !
> >
>
> --
> *Emmanuel Lécharny* P. +33 (0)6 08 33 32 61
> elecha...@apache.org
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
> For additional commands, e-mail: dev-h...@mina.apache.org
>


--

Guillaume Nodet

-
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org