Commits

Sebastian Sdorra committed 20b168a

improve port configuration

Comments (0)

Files changed (3)

scm-core/src/main/java/sonia/scm/config/ScmConfiguration.java

     this.pluginUrl = other.pluginUrl;
     this.sslPort = other.sslPort;
     this.enableSSL = other.enableSSL;
-    this.port = other.port;
+    this.enablePortForward = other.enablePortForward;
+    this.forwardPort = other.forwardPort;
     this.anonymousAccessEnabled = other.anonymousAccessEnabled;
     this.adminUsers = other.adminUsers;
     this.adminGroups = other.adminGroups;
    *
    * @return
    */
-  public String getPluginUrl()
+  public int getForwardPort()
   {
-    return pluginUrl;
+    return forwardPort;
   }
 
   /**
    *
    * @return
    */
-  public int getPort()
+  public String getPluginUrl()
   {
-    return port;
+    return pluginUrl;
   }
 
   /**
    *
    * @return
    */
+  public boolean isEnablePortForward()
+  {
+    return enablePortForward;
+  }
+
+  /**
+   * Method description
+   *
+   *
+   * @return
+   */
   public boolean isEnableSSL()
   {
     return enableSSL;
    * Method description
    *
    *
+   * @param enablePortForward
+   */
+  public void setEnablePortForward(boolean enablePortForward)
+  {
+    this.enablePortForward = enablePortForward;
+  }
+
+  /**
+   * Method description
+   *
+   *
    * @param enableSSL
    */
   public void setEnableSSL(boolean enableSSL)
    * Method description
    *
    *
+   * @param forwardPort
+   */
+  public void setForwardPort(int forwardPort)
+  {
+    this.forwardPort = forwardPort;
+  }
+
+  /**
+   * Method description
+   *
+   *
    * @param pluginUrl
    */
   public void setPluginUrl(String pluginUrl)
    * Method description
    *
    *
-   * @param port
-   */
-  public void setPort(int port)
-  {
-    this.port = port;
-  }
-
-  /**
-   * Method description
-   *
-   *
    * @param servername
    */
   public void setServername(String servername)
   private Set<String> adminUsers;
 
   /** Field description */
+  private int forwardPort = 80;
+
+  /** Field description */
   @XmlElement(name = "plugin-url")
   private String pluginUrl = DEFAULT_PLUGINURL;
 
   /** Field description */
-  private int port = -1;
-
-  /** Field description */
   private String servername = "localhost";
 
   /** Field description */
   private boolean enableSSL = false;
 
   /** Field description */
+  private boolean enablePortForward = false;
+
+  /** Field description */
   private int sslPort = 8181;
 
   /** Field description */

scm-core/src/main/java/sonia/scm/util/HttpUtil.java

     {
       port = configuration.getSslPort();
     }
+    else if (configuration.isEnablePortForward())
+    {
+      port = configuration.getForwardPort();
+    }
     else
     {
-      port = configuration.getPort();
-    }
-
-    if (port <= 0)
-    {
       port = request.getLocalPort();
     }
 

scm-webapp/src/main/webapp/resources/js/sonia.config.js

           name: 'servername',
           allowBlank: false
         },{
+          xtype: 'checkbox',
+          fieldLabel: 'Enable forwarding (mod_proxy)',
+          name: 'enablePortForward',
+          inputValue: 'true',
+          listeners: {
+            check: function(){
+              Ext.getCmp('serverport').setDisabled( ! this.checked );
+            }
+          }
+        },{
+          id: 'serverport',
           xtype: 'numberfield',
-          fieldLabel: 'Serverport',
-          name: 'port',
+          fieldLabel: 'Forward Port',
+          name: 'forwardPort',
+          disabled: true,
           allowBlank: false
         },{
           xtype: 'textfield',
           xtype: 'checkbox',
           fieldLabel: 'Enable SSL',
           name: 'enableSSL',
-          inputValue: 'true'
+          inputValue: 'true',
+          listeners: {
+            check: function(){
+              Ext.getCmp('sslPort').setDisabled( ! this.checked );
+            }
+          }
         },{
+          id: 'sslPort',
           xtype: 'numberfield',
           fieldLabel: 'SSL Port',
           name: 'sslPort',
+          disabled: true,
           allowBlank: false
         },{
           xtype : 'textfield',
         }],
       
         onSubmit: function(values){
+          if ( ! values.enableSSL ){
+            values.sslPort = Ext.getCmp('sslPort').getValue();
+          }
+          if ( ! values.enablePortForward ){
+            values.forwardPort = Ext.getCmp('serverport').getValue();
+          }
           this.el.mask('Submit ...');
           Ext.Ajax.request({
             url: restUrl + 'config.json',
             success: function(response){
               var obj = Ext.decode(response.responseText);
               this.load(obj);
+              if ( obj.enablePortForward ){
+                Ext.getCmp('serverport').setDisabled(false);
+              }
+              if ( obj.enableSSL ){
+                Ext.getCmp('sslPort').setDisabled(false);
+              }
               clearTimeout(tid);
               el.unmask();
             },
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.