lawmin2021 commented on issue #609:
URL: https://github.com/apache/mina-sshd/issues/609#issuecomment-2362246015

   I made the following change to pass my case, hope it work for 
[GH-318](https://github.com/apache/mina-sshd/issues/318) Handle cascaded proxy 
jumps
   
   protected List<HostConfigEntry> parseProxyJumps(HostConfigEntry entry, 
AttributeRepository context)
               throws IOException {
           List<HostConfigEntry> hops;
           try {
               hops = parseProxyJumps(entry.getProxyJump(), context);
               if (GenericUtils.isEmpty(hops)) {
                   return hops;
               }
               // If the last entry itself has proxy jumps, we need to append 
them. Guard against possible proxy jump
               // loops by imposing an upper limit on the total number of jumps.
               for (;;) {
                   HostConfigEntry last = hops.get(hops.size() - 1);
                   try {
                       List<HostConfigEntry> additionalHops = 
parseProxyJumps(last.getProxyJump(), context);
                       if (additionalHops.isEmpty()) {
                           break;
                       } else {
                           boolean isFound = false;
                           for (HostConfigEntry checkAddHop : additionalHops) {
                               for (HostConfigEntry checkHop : hops) {
                                   String fullHopStr = checkHop.toString();
                                   String fullAddHopStr = 
checkAddHop.toString();
                                   if (fullHopStr.equals(fullAddHopStr)) {
                                       isFound = true;
                                       break;
                                   }
                               }
                               if (!isFound) {
                                   hops.add(checkAddHop);
                               }
   
                           }
   
                           if (isFound) {
                               return hops;
                           }
   
                           if (hops.size() > 
CoreModuleProperties.MAX_PROXY_JUMPS.getRequired(this)) {
                               throw new IllegalArgumentException("Too many 
proxy jumps for host " + entry.getHost());
                           }
                       }
                   } catch (IOException | RuntimeException e) {
                       throw new IllegalArgumentException("Problem parsing 
proxyJump from host config " + last.getHost(), e);
                   }
               }
           } catch (IOException | RuntimeException e) {
               throw new IllegalArgumentException("Problem parsing proxyJump 
from host config " + entry.getHost(), e);
           }
           return hops;
       }


-- 
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

Reply via email to