├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.adoc ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── io │ │ └── igx │ │ └── proxy │ │ ├── TcpProxyApplication.java │ │ ├── controllers │ │ └── ServerController.java │ │ ├── domain │ │ ├── ConnectionStats.java │ │ ├── CreateProxyRequest.java │ │ ├── ProxyDefinition.java │ │ ├── Qos.java │ │ ├── ServerNotFoundException.java │ │ └── TrafficShaping.java │ │ ├── handlers │ │ ├── GlobalConnectionCounterHandler.java │ │ ├── ProxyBackendHandler.java │ │ ├── ProxyFrontendHandler.java │ │ └── ProxyInitializer.java │ │ └── services │ │ ├── AbstractProxyServer.java │ │ ├── NettyServerService.java │ │ ├── NettyServerServiceImpl.java │ │ ├── ProxyServer.java │ │ └── TCPProxyServer.java └── resources │ ├── application.properties │ └── static │ ├── css │ ├── angular-chart.css │ ├── awesomeRating.css │ ├── bootstrap.min.css │ ├── font-awesome.min.css │ ├── materialize.min.css │ └── tcpproxy.css │ ├── favicon.ico │ ├── fonts │ ├── material-design-icons │ │ ├── LICENSE.txt │ │ ├── Material-Design-Icons.eot │ │ ├── Material-Design-Icons.svg │ │ ├── Material-Design-Icons.ttf │ │ ├── Material-Design-Icons.woff │ │ └── Material-Design-Icons.woff2 │ └── roboto │ │ ├── Roboto-Bold.eot │ │ ├── Roboto-Bold.ttf │ │ ├── Roboto-Bold.woff │ │ ├── Roboto-Bold.woff2 │ │ ├── Roboto-Light.eot │ │ ├── Roboto-Light.ttf │ │ ├── Roboto-Light.woff │ │ ├── Roboto-Light.woff2 │ │ ├── Roboto-Medium.eot │ │ ├── Roboto-Medium.ttf │ │ ├── Roboto-Medium.woff │ │ ├── Roboto-Medium.woff2 │ │ ├── Roboto-Regular.eot │ │ ├── Roboto-Regular.ttf │ │ ├── Roboto-Regular.woff │ │ ├── Roboto-Regular.woff2 │ │ ├── Roboto-Thin.eot │ │ ├── Roboto-Thin.ttf │ │ ├── Roboto-Thin.woff │ │ └── Roboto-Thin.woff2 │ ├── images │ ├── off.png │ └── on.png │ ├── index.html │ ├── js │ ├── Chart.js │ ├── angular-chart.js │ ├── angular-chart.min.js │ ├── angular-cookies.js │ ├── angular-materialize.min.js │ ├── angular-pageslide-directive.min.js │ ├── angular-route.js │ ├── angular.js │ ├── app.js │ ├── home.js │ ├── jquery.min.js │ ├── materialize.min.js │ └── proxy.js │ └── views │ ├── home.html │ └── proxy.html └── test └── java └── io └── igx └── proxy ├── TcpProxyApplicationTests.java ├── TrafficGeneratorClientHandler.java └── TrafficSimulationTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | /application.yml 2 | /application.properties 3 | asciidoctor.css 4 | *~ 5 | .#* 6 | *# 7 | target/ 8 | build/ 9 | bin/ 10 | _site/ 11 | .classpath 12 | .project 13 | .settings 14 | .springBeans 15 | .DS_Store 16 | *.sw* 17 | *.iml 18 | *.ipr 19 | *.iws 20 | .idea/* 21 | .factorypath 22 | spring-xd-samples/*/xd 23 | dump.rdb 24 | .apt_generated 25 | artifacts 26 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = nano-proxy 2 | Because everything is micro these days 3 | 4 | == What 5 | 6 | Started as an excuse to play with the amazing 7 | http://netty.io[netty] framework. I just needed to proxy 8 | traffic from a private network (10.0.0.x) via a public machine. 9 | 10 | Then I realized I could play with a bunch of cool stuff (Traffic shaping, hex dumps, connection control, load balancing) 11 | 12 | == WIP 13 | 14 | Not really usable, at the moment. but I had to start pushing something to github. 15 | 16 | == Wish list 17 | 18 | * [ ] TCP and HTTP proxies 19 | * [ ] Channel Pooling 20 | * [ ] Load balancing with ribbon 21 | * [ ] Tests, tests, tests 22 | 23 | == Screenshots 24 | 25 | 26 | image::https://cloud.githubusercontent.com/assets/803893/15525026/638a406a-21f4-11e6-90ec-4c68bf81b02e.png[] 27 | 28 | 29 | image::https://cloud.githubusercontent.com/assets/803893/15525029/6a81ec4c-21f4-11e6-84fe-de6f3e3ed828.png[] 30 | 31 | 32 | image::https://cloud.githubusercontent.com/assets/803893/15525034/70558fde-21f4-11e6-9fcd-5d3926872442.png[] 33 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # 58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 59 | # for the new JDKs provided by Oracle. 60 | # 61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 62 | # 63 | # Apple JDKs 64 | # 65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 66 | fi 67 | 68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 69 | # 70 | # Apple JDKs 71 | # 72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 73 | fi 74 | 75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 76 | # 77 | # Oracle JDKs 78 | # 79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 80 | fi 81 | 82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 83 | # 84 | # Apple JDKs 85 | # 86 | export JAVA_HOME=`/usr/libexec/java_home` 87 | fi 88 | ;; 89 | esac 90 | 91 | if [ -z "$JAVA_HOME" ] ; then 92 | if [ -r /etc/gentoo-release ] ; then 93 | JAVA_HOME=`java-config --jre-home` 94 | fi 95 | fi 96 | 97 | if [ -z "$M2_HOME" ] ; then 98 | ## resolve links - $0 may be a link to maven's home 99 | PRG="$0" 100 | 101 | # need this for relative symlinks 102 | while [ -h "$PRG" ] ; do 103 | ls=`ls -ld "$PRG"` 104 | link=`expr "$ls" : '.*-> \(.*\)$'` 105 | if expr "$link" : '/.*' > /dev/null; then 106 | PRG="$link" 107 | else 108 | PRG="`dirname "$PRG"`/$link" 109 | fi 110 | done 111 | 112 | saveddir=`pwd` 113 | 114 | M2_HOME=`dirname "$PRG"`/.. 115 | 116 | # make it fully qualified 117 | M2_HOME=`cd "$M2_HOME" && pwd` 118 | 119 | cd "$saveddir" 120 | # echo Using m2 at $M2_HOME 121 | fi 122 | 123 | # For Cygwin, ensure paths are in UNIX format before anything is touched 124 | if $cygwin ; then 125 | [ -n "$M2_HOME" ] && 126 | M2_HOME=`cygpath --unix "$M2_HOME"` 127 | [ -n "$JAVA_HOME" ] && 128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 129 | [ -n "$CLASSPATH" ] && 130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 131 | fi 132 | 133 | # For Migwn, ensure paths are in UNIX format before anything is touched 134 | if $mingw ; then 135 | [ -n "$M2_HOME" ] && 136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 137 | [ -n "$JAVA_HOME" ] && 138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 139 | # TODO classpath? 140 | fi 141 | 142 | if [ -z "$JAVA_HOME" ]; then 143 | javaExecutable="`which javac`" 144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 145 | # readlink(1) is not available as standard on Solaris 10. 146 | readLink=`which readlink` 147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 148 | if $darwin ; then 149 | javaHome="`dirname \"$javaExecutable\"`" 150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 151 | else 152 | javaExecutable="`readlink -f \"$javaExecutable\"`" 153 | fi 154 | javaHome="`dirname \"$javaExecutable\"`" 155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 156 | JAVA_HOME="$javaHome" 157 | export JAVA_HOME 158 | fi 159 | fi 160 | fi 161 | 162 | if [ -z "$JAVACMD" ] ; then 163 | if [ -n "$JAVA_HOME" ] ; then 164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 165 | # IBM's JDK on AIX uses strange locations for the executables 166 | JAVACMD="$JAVA_HOME/jre/sh/java" 167 | else 168 | JAVACMD="$JAVA_HOME/bin/java" 169 | fi 170 | else 171 | JAVACMD="`which java`" 172 | fi 173 | fi 174 | 175 | if [ ! -x "$JAVACMD" ] ; then 176 | echo "Error: JAVA_HOME is not defined correctly." >&2 177 | echo " We cannot execute $JAVACMD" >&2 178 | exit 1 179 | fi 180 | 181 | if [ -z "$JAVA_HOME" ] ; then 182 | echo "Warning: JAVA_HOME environment variable is not set." 183 | fi 184 | 185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 186 | 187 | # For Cygwin, switch paths to Windows format before running java 188 | if $cygwin; then 189 | [ -n "$M2_HOME" ] && 190 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 191 | [ -n "$JAVA_HOME" ] && 192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 193 | [ -n "$CLASSPATH" ] && 194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 195 | fi 196 | 197 | # traverses directory structure from process work directory to filesystem root 198 | # first directory with .mvn subdirectory is considered project base directory 199 | find_maven_basedir() { 200 | local basedir=$(pwd) 201 | local wdir=$(pwd) 202 | while [ "$wdir" != '/' ] ; do 203 | if [ -d "$wdir"/.mvn ] ; then 204 | basedir=$wdir 205 | break 206 | fi 207 | wdir=$(cd "$wdir/.."; pwd) 208 | done 209 | echo "${basedir}" 210 | } 211 | 212 | # concatenates all lines of a file 213 | concat_lines() { 214 | if [ -f "$1" ]; then 215 | echo "$(tr -s '\n' ' ' < "$1")" 216 | fi 217 | } 218 | 219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 221 | 222 | # Provide a "standardized" way to retrieve the CLI args that will 223 | # work with both Windows and non-Windows executions. 224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 225 | export MAVEN_CMD_LINE_ARGS 226 | 227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 228 | 229 | exec "$JAVACMD" \ 230 | $MAVEN_OPTS \ 231 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 232 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 233 | ${WRAPPER_LAUNCHER} "$@" 234 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | 121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" 122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 123 | 124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% 125 | if ERRORLEVEL 1 goto error 126 | goto end 127 | 128 | :error 129 | set ERROR_CODE=1 130 | 131 | :end 132 | @endlocal & set ERROR_CODE=%ERROR_CODE% 133 | 134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 138 | :skipRcPost 139 | 140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 142 | 143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 144 | 145 | exit /B %ERROR_CODE% -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.igx.proxy 7 | tcp-proxy 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | tcp-proxy 12 | Simple TCP proxy using Netty 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.3.5.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | 1.8 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-actuator 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | 37 | io.netty 38 | netty-all 39 | 4.1.0.CR3 40 | 41 | 42 | org.webjars 43 | bootstrap 44 | 3.3.6 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-maven-plugin 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/TcpProxyApplication.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class TcpProxyApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(TcpProxyApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/controllers/ServerController.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.controllers; 2 | 3 | import java.util.Map; 4 | 5 | import io.igx.proxy.domain.ConnectionStats; 6 | import io.igx.proxy.domain.CreateProxyRequest; 7 | import io.igx.proxy.domain.ProxyDefinition; 8 | import io.igx.proxy.domain.TrafficShaping; 9 | import io.igx.proxy.services.NettyServerService; 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.http.HttpStatus; 13 | import org.springframework.http.ResponseEntity; 14 | import org.springframework.web.bind.annotation.PathVariable; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestMethod; 18 | import org.springframework.web.bind.annotation.RestController; 19 | 20 | /** 21 | * @author Vinicius Carvalho 22 | */ 23 | @RestController 24 | @RequestMapping(value = "/servers") 25 | public class ServerController { 26 | 27 | private NettyServerService service; 28 | 29 | @Autowired 30 | public ServerController(NettyServerService service) { 31 | this.service = service; 32 | } 33 | 34 | @RequestMapping(method = RequestMethod.POST) 35 | public ResponseEntity createServer(@RequestBody CreateProxyRequest createProxyRequest){ 36 | ProxyDefinition definition = service.createServer(createProxyRequest); 37 | ResponseEntity response = new ResponseEntity(definition, HttpStatus.CREATED); 38 | return response; 39 | } 40 | 41 | @RequestMapping(method = RequestMethod.GET, value = "/{id}", produces = "application/json") 42 | public ResponseEntity getProxyDefinition(@PathVariable("id") String id){ 43 | return new ResponseEntity(service.getProxyDefinition(id),HttpStatus.OK); 44 | } 45 | 46 | @RequestMapping(method = RequestMethod.GET, produces = "application/json") 47 | public ResponseEntity listServers(){ 48 | return new ResponseEntity(service.listServers(),HttpStatus.OK); 49 | } 50 | @RequestMapping(method = RequestMethod.POST, value = "/{id}/status") 51 | public ResponseEntity toggle(@RequestBody Map status, @PathVariable("id") String id){ 52 | Boolean active = (Boolean) status.get("active"); 53 | if(!active){ 54 | service.stopServer(id); 55 | }else{ 56 | service.startServer(id); 57 | } 58 | return new ResponseEntity(HttpStatus.OK); 59 | } 60 | 61 | @RequestMapping(method = RequestMethod.GET, value = "/{id}/stats") 62 | public ResponseEntity getStats(@PathVariable("id") String id){ 63 | ConnectionStats stats = service.getStats(id); 64 | return new ResponseEntity(stats,HttpStatus.OK); 65 | } 66 | 67 | @RequestMapping(method = RequestMethod.POST, value = "/{id}/traffic") 68 | public ResponseEntity updateTrafficConfiguration(@PathVariable("id") String id, @RequestBody TrafficShaping config){ 69 | service.configureTraffic(id,config); 70 | ProxyDefinition definition = service.getProxyDefinition(id); 71 | return new ResponseEntity(definition,HttpStatus.OK); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/domain/ConnectionStats.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.domain; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | import java.util.concurrent.atomic.AtomicLong; 5 | 6 | /** 7 | * @author Vinicius Carvalho 8 | */ 9 | public class ConnectionStats { 10 | 11 | private AtomicInteger connectionCount = new AtomicInteger(0); 12 | private AtomicLong bytesSent = new AtomicLong(0L); 13 | private AtomicLong bytesReceived = new AtomicLong(0L); 14 | 15 | public ConnectionStats(){} 16 | public ConnectionStats(long bytesSent, long bytesReceived){ 17 | this.bytesSent.set(bytesSent); 18 | this.bytesReceived.set(bytesReceived); 19 | } 20 | 21 | public int increaseConnectionCount(){ 22 | return connectionCount.incrementAndGet(); 23 | } 24 | 25 | public int decreaseConnectionCount(){ 26 | return connectionCount.decrementAndGet(); 27 | } 28 | 29 | public long appendBytesSent(long delta){ 30 | return bytesSent.getAndAdd(delta); 31 | } 32 | 33 | public long appendBytesReceived(long delta){ 34 | return bytesReceived.getAndAdd(delta); 35 | } 36 | 37 | 38 | 39 | public AtomicLong getBytesReceived() { 40 | return bytesReceived; 41 | } 42 | 43 | public Long getBytesSent(){ 44 | return bytesSent.get(); 45 | } 46 | 47 | public Integer getConnectionCount(){ 48 | return connectionCount.get(); 49 | } 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/domain/CreateProxyRequest.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.domain; 2 | 3 | /** 4 | * @author Vinicius Carvalho 5 | */ 6 | public class CreateProxyRequest { 7 | 8 | private String alias; 9 | private Integer remotePort; 10 | private String remoteHost; 11 | private boolean debug; 12 | private Integer localPort; 13 | 14 | public Integer getRemotePort() { 15 | return remotePort; 16 | } 17 | 18 | public void setRemotePort(Integer remotePort) { 19 | this.remotePort = remotePort; 20 | } 21 | 22 | public String getRemoteHost() { 23 | return remoteHost; 24 | } 25 | 26 | public void setRemoteHost(String remoteHost) { 27 | this.remoteHost = remoteHost; 28 | } 29 | 30 | public boolean isDebug() { 31 | return debug; 32 | } 33 | 34 | public void setDebug(boolean debug) { 35 | this.debug = debug; 36 | } 37 | 38 | public Integer getLocalPort() { 39 | return localPort; 40 | } 41 | 42 | public void setLocalPort(Integer localPort) { 43 | this.localPort = localPort; 44 | } 45 | 46 | public String getAlias() { 47 | return alias; 48 | } 49 | 50 | public void setAlias(String alias) { 51 | this.alias = alias; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/domain/ProxyDefinition.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.domain; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * @author Vinicius Carvalho 7 | */ 8 | public class ProxyDefinition { 9 | private String alias; 10 | private final long startedTime; 11 | private final String id; 12 | private Integer remotePort; 13 | private String remoteHost; 14 | private boolean debug; 15 | private Integer localPort; 16 | private boolean active = false; 17 | private ConnectionStats connectionStats; 18 | private Qos qos; 19 | 20 | public ProxyDefinition(CreateProxyRequest request){ 21 | 22 | this.id = UUID.randomUUID().toString(); 23 | this.startedTime = System.currentTimeMillis(); 24 | this.connectionStats = new ConnectionStats(); 25 | this.qos = new Qos(); 26 | this.remoteHost = request.getRemoteHost(); 27 | this.remotePort = request.getRemotePort(); 28 | this.localPort = request.getLocalPort(); 29 | this.alias = request.getAlias(); 30 | 31 | } 32 | 33 | 34 | 35 | public Integer getRemotePort() { 36 | return remotePort; 37 | } 38 | 39 | public void setRemotePort(Integer remotePort) { 40 | this.remotePort = remotePort; 41 | } 42 | 43 | public String getRemoteHost() { 44 | return remoteHost; 45 | } 46 | 47 | public void setRemoteHost(String remoteHost) { 48 | this.remoteHost = remoteHost; 49 | } 50 | 51 | public boolean isDebug() { 52 | return debug; 53 | } 54 | 55 | public void setDebug(boolean debug) { 56 | this.debug = debug; 57 | } 58 | 59 | public Integer getLocalPort() { 60 | return localPort; 61 | } 62 | 63 | public void setLocalPort(Integer localPort) { 64 | this.localPort = localPort; 65 | } 66 | 67 | public String getId() { 68 | return id; 69 | } 70 | 71 | public String getAlias() { 72 | return alias; 73 | } 74 | 75 | public void setAlias(String alias) { 76 | this.alias = alias; 77 | } 78 | 79 | public ConnectionStats getConnectionStats() { 80 | return connectionStats; 81 | } 82 | 83 | public void setConnectionStats(ConnectionStats connectionStats) { 84 | this.connectionStats = connectionStats; 85 | } 86 | 87 | public long getStartedTime() { 88 | return startedTime; 89 | } 90 | 91 | public boolean isActive() { 92 | return active; 93 | } 94 | 95 | public void setActive(boolean active) { 96 | this.active = active; 97 | } 98 | 99 | public Qos getQos() { 100 | return qos; 101 | } 102 | 103 | public void setQos(Qos qos) { 104 | this.qos = qos; 105 | } 106 | 107 | @Override 108 | public boolean equals(Object o) { 109 | if (this == o) return true; 110 | if (o == null || getClass() != o.getClass()) return false; 111 | 112 | ProxyDefinition that = (ProxyDefinition) o; 113 | 114 | return id.equals(that.id); 115 | 116 | } 117 | 118 | @Override 119 | public int hashCode() { 120 | return id.hashCode(); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/domain/Qos.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.domain; 2 | 3 | /** 4 | * @author Vinicius Carvalho 5 | */ 6 | public class Qos { 7 | 8 | private TrafficShaping trafficShaping; 9 | 10 | public TrafficShaping getTrafficShaping() { 11 | return trafficShaping; 12 | } 13 | 14 | public void setTrafficShaping(TrafficShaping trafficShapping) { 15 | this.trafficShaping = trafficShapping; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/domain/ServerNotFoundException.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.domain; 2 | 3 | /** 4 | * @author Vinicius Carvalho 5 | */ 6 | public class ServerNotFoundException extends RuntimeException { 7 | public ServerNotFoundException(String message, Throwable cause) { 8 | super(message, cause); 9 | } 10 | 11 | public ServerNotFoundException(String message) { 12 | super(message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/domain/TrafficShaping.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.domain; 2 | 3 | /** 4 | * @author Vinicius Carvalho 5 | */ 6 | public class TrafficShaping { 7 | private long writeLimit; 8 | private long readLimit; 9 | private long checkInterval; 10 | private long maxTime; 11 | 12 | public static final long DEFAULT_CHECK_INTERVAL = 1000l; 13 | public static final long DEFAULT_MAX_TIME = 1000l; 14 | 15 | public TrafficShaping(){} 16 | public TrafficShaping(long writeLimit, long readLimit) { 17 | this(writeLimit,readLimit, DEFAULT_CHECK_INTERVAL,DEFAULT_MAX_TIME); 18 | } 19 | 20 | public TrafficShaping(long writeLimit, long readLimit, long checkInterval, long maxTime) { 21 | this.writeLimit = writeLimit; 22 | this.readLimit = readLimit; 23 | this.checkInterval = checkInterval; 24 | this.maxTime = maxTime; 25 | } 26 | 27 | public long getWriteLimit() { 28 | return writeLimit; 29 | } 30 | 31 | public void setWriteLimit(long writeLimit) { 32 | this.writeLimit = writeLimit; 33 | } 34 | 35 | public long getReadLimit() { 36 | return readLimit; 37 | } 38 | 39 | public void setReadLimit(long readLimit) { 40 | this.readLimit = readLimit; 41 | } 42 | 43 | public long getCheckInterval() { 44 | return checkInterval; 45 | } 46 | 47 | public void setCheckInterval(long checkInterval) { 48 | this.checkInterval = checkInterval; 49 | } 50 | 51 | public long getMaxTime() { 52 | return maxTime; 53 | } 54 | 55 | public void setMaxTime(long maxTime) { 56 | this.maxTime = maxTime; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/handlers/GlobalConnectionCounterHandler.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.handlers; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import io.netty.channel.ChannelHandlerContext; 6 | import io.netty.channel.ChannelInboundHandlerAdapter; 7 | 8 | /** 9 | * @author Vinicius Carvalho 10 | */ 11 | public class GlobalConnectionCounterHandler extends ChannelInboundHandlerAdapter{ 12 | 13 | private volatile Integer maxConnections = -1; 14 | private AtomicInteger counter; 15 | 16 | public GlobalConnectionCounterHandler(Integer maxConnections) { 17 | this.maxConnections = maxConnections; 18 | counter = new AtomicInteger(0); 19 | } 20 | 21 | @Override 22 | public void channelActive(ChannelHandlerContext ctx) throws Exception { 23 | if(maxConnections > -1){ 24 | if(counter.get() < maxConnections) 25 | counter.incrementAndGet(); 26 | else 27 | ctx.close(); 28 | } 29 | 30 | } 31 | 32 | @Override 33 | public void channelInactive(ChannelHandlerContext ctx) throws Exception { 34 | if(maxConnections > -1) { 35 | counter.decrementAndGet(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/handlers/ProxyBackendHandler.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.handlers; 2 | 3 | import io.igx.proxy.domain.ProxyDefinition; 4 | import io.netty.buffer.ByteBuf; 5 | import io.netty.channel.Channel; 6 | import io.netty.channel.ChannelFuture; 7 | import io.netty.channel.ChannelFutureListener; 8 | import io.netty.channel.ChannelHandlerContext; 9 | import io.netty.channel.ChannelInboundHandlerAdapter; 10 | 11 | /** 12 | * @author Vinicius Carvalho 13 | * Taken from: https://github.com/netty/netty/blob/4.1/example/src/main/java/io/netty/example/proxy/HexDumpProxyBackendHandler.java 14 | */ 15 | public class ProxyBackendHandler extends ChannelInboundHandlerAdapter { 16 | 17 | private final Channel inboundChannel; 18 | private final ProxyDefinition proxyDefinition; 19 | 20 | public ProxyBackendHandler(Channel inboundChannel, ProxyDefinition proxyDefinition) { 21 | this.inboundChannel = inboundChannel; 22 | this.proxyDefinition = proxyDefinition; 23 | } 24 | 25 | @Override 26 | public void channelActive(ChannelHandlerContext ctx) { 27 | ctx.read(); 28 | } 29 | 30 | @Override 31 | public void channelRead(final ChannelHandlerContext ctx, Object msg) { 32 | if (ByteBuf.class.isAssignableFrom(msg.getClass())){ 33 | proxyDefinition.getConnectionStats().appendBytesReceived(((ByteBuf)msg).capacity()); 34 | } 35 | 36 | inboundChannel.writeAndFlush(msg).addListener(new ChannelFutureListener() { 37 | @Override 38 | public void operationComplete(ChannelFuture future) { 39 | if (future.isSuccess()) { 40 | ctx.channel().read(); 41 | } else { 42 | future.channel().close(); 43 | } 44 | } 45 | }); 46 | } 47 | 48 | @Override 49 | public void channelInactive(ChannelHandlerContext ctx) { 50 | ProxyFrontendHandler.closeOnFlush(inboundChannel); 51 | } 52 | 53 | @Override 54 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { 55 | cause.printStackTrace(); 56 | ProxyFrontendHandler.closeOnFlush(ctx.channel()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/handlers/ProxyFrontendHandler.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.handlers; 2 | 3 | import io.igx.proxy.domain.ProxyDefinition; 4 | import io.netty.bootstrap.Bootstrap; 5 | import io.netty.buffer.ByteBuf; 6 | import io.netty.buffer.Unpooled; 7 | import io.netty.channel.Channel; 8 | import io.netty.channel.ChannelFuture; 9 | import io.netty.channel.ChannelFutureListener; 10 | import io.netty.channel.ChannelHandlerContext; 11 | import io.netty.channel.ChannelInboundHandlerAdapter; 12 | import io.netty.channel.ChannelOption; 13 | 14 | /** 15 | * @author Vinicius Carvalho 16 | * Taken from https://github.com/netty/netty/blob/4.1/example/src/main/java/io/netty/example/proxy/HexDumpProxyFrontendHandler.java 17 | */ 18 | public class ProxyFrontendHandler extends ChannelInboundHandlerAdapter { 19 | 20 | private ProxyDefinition proxyDefinition; 21 | private volatile Channel outboundChannel; 22 | 23 | public ProxyFrontendHandler(ProxyDefinition proxyDefinition) { 24 | this.proxyDefinition = proxyDefinition; 25 | } 26 | 27 | @Override 28 | public void channelActive(ChannelHandlerContext ctx) { 29 | final Channel inboundChannel = ctx.channel(); 30 | // Start the connection attempt. 31 | Bootstrap b = new Bootstrap(); 32 | b.group(inboundChannel.eventLoop()) 33 | .channel(ctx.channel().getClass()) 34 | .handler(new ProxyBackendHandler(inboundChannel, proxyDefinition)) 35 | .option(ChannelOption.AUTO_READ, false); 36 | ChannelFuture f = b.connect(proxyDefinition.getRemoteHost(), proxyDefinition.getRemotePort()); 37 | outboundChannel = f.channel(); 38 | f.addListener(new ChannelFutureListener() { 39 | @Override 40 | public void operationComplete(ChannelFuture future) { 41 | if (future.isSuccess()) { 42 | // connection complete start to read first data 43 | inboundChannel.read(); 44 | } else { 45 | // Close the connection if the connection attempt has failed. 46 | inboundChannel.close(); 47 | } 48 | } 49 | }); 50 | } 51 | @Override 52 | public void channelRead(final ChannelHandlerContext ctx, Object msg) { 53 | if (outboundChannel.isActive()) { 54 | if (ByteBuf.class.isAssignableFrom(msg.getClass())){ 55 | proxyDefinition.getConnectionStats().appendBytesSent(((ByteBuf)msg).capacity()); 56 | } 57 | outboundChannel.writeAndFlush(msg).addListener(new ChannelFutureListener() { 58 | @Override 59 | public void operationComplete(ChannelFuture future) { 60 | if (future.isSuccess()) { 61 | // was able to flush out data, start to read the next chunk 62 | ctx.channel().read(); 63 | } else { 64 | future.channel().close(); 65 | } 66 | } 67 | }); 68 | } 69 | } 70 | 71 | @Override 72 | public void channelInactive(ChannelHandlerContext ctx) { 73 | if (outboundChannel != null) { 74 | closeOnFlush(outboundChannel); 75 | } 76 | } 77 | 78 | @Override 79 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { 80 | cause.printStackTrace(); 81 | closeOnFlush(ctx.channel()); 82 | } 83 | 84 | /** 85 | * Closes the specified channel after all queued write requests are flushed. 86 | */ 87 | static void closeOnFlush(Channel ch) { 88 | if (ch.isActive()) { 89 | ch.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/handlers/ProxyInitializer.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.handlers; 2 | 3 | import io.igx.proxy.domain.ProxyDefinition; 4 | import io.netty.channel.ChannelInitializer; 5 | import io.netty.channel.socket.SocketChannel; 6 | import io.netty.handler.traffic.AbstractTrafficShapingHandler; 7 | 8 | /** 9 | * @author Vinicius Carvalho 10 | */ 11 | public class ProxyInitializer extends ChannelInitializer { 12 | 13 | 14 | private final ProxyDefinition proxyDefinition; 15 | private final AbstractTrafficShapingHandler trafficShapingHandler; 16 | 17 | public ProxyInitializer(ProxyDefinition proxyDefinition, AbstractTrafficShapingHandler trafficShapingHandler) { 18 | this.proxyDefinition = proxyDefinition; 19 | this.trafficShapingHandler = trafficShapingHandler; 20 | } 21 | 22 | 23 | 24 | @Override 25 | protected void initChannel(SocketChannel ch) throws Exception { 26 | ch.pipeline().addLast(trafficShapingHandler, 27 | new ProxyFrontendHandler(proxyDefinition)); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/services/AbstractProxyServer.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.services; 2 | 3 | import io.igx.proxy.domain.ConnectionStats; 4 | import io.igx.proxy.domain.ProxyDefinition; 5 | import io.igx.proxy.domain.TrafficShaping; 6 | import io.netty.channel.Channel; 7 | import io.netty.channel.EventLoopGroup; 8 | import io.netty.handler.traffic.AbstractTrafficShapingHandler; 9 | import io.netty.handler.traffic.GlobalChannelTrafficShapingHandler; 10 | import io.netty.util.concurrent.Future; 11 | import io.netty.util.concurrent.GenericFutureListener; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | 15 | /** 16 | * @author Vinicius Carvalho 17 | */ 18 | public abstract class AbstractProxyServer implements ProxyServer { 19 | 20 | protected final ProxyDefinition definition; 21 | protected AbstractTrafficShapingHandler trafficHandler; 22 | protected Channel serverChannel; 23 | protected volatile boolean running = false; 24 | private Logger logger = LoggerFactory.getLogger(getClass()); 25 | 26 | public AbstractProxyServer(ProxyDefinition definition) { 27 | this.definition = definition; 28 | } 29 | 30 | 31 | protected abstract Channel doStart(EventLoopGroup bossGroup, EventLoopGroup workerGroup); 32 | 33 | @Override 34 | public void start(EventLoopGroup bossGroup, EventLoopGroup workerGroup) { 35 | createTrafficHandler(workerGroup); 36 | this.serverChannel = doStart(bossGroup, workerGroup); 37 | running = true; 38 | definition.setActive(true); 39 | } 40 | 41 | @Override 42 | public void stop() { 43 | if(serverChannel != null && running){ 44 | logger.info("Shutting down server: {} on port {}",definition.getId(),definition.getLocalPort()); 45 | serverChannel.close().addListener(new GenericFutureListener>() { 46 | @Override 47 | public void operationComplete(Future future) throws Exception { 48 | running = false; 49 | definition.setActive(false); 50 | serverChannel = null; 51 | logger.info("Server {} shutdown complete",definition.getId()); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | public ConnectionStats getStats(){ 58 | if(!running) 59 | return new ConnectionStats(0,0); 60 | 61 | return new ConnectionStats(trafficHandler.trafficCounter().lastWrittenBytes(),trafficHandler.trafficCounter().lastReadBytes()); 62 | } 63 | 64 | private void createTrafficHandler(EventLoopGroup workerGroup){ 65 | if(definition.getQos().getTrafficShaping() != null){ 66 | TrafficShaping tf = definition.getQos().getTrafficShaping(); 67 | this.trafficHandler = new GlobalChannelTrafficShapingHandler(workerGroup,tf.getWriteLimit(),tf.getReadLimit(),0,0,tf.getCheckInterval(),tf.getMaxTime()); 68 | }else{ 69 | this.trafficHandler = new GlobalChannelTrafficShapingHandler(workerGroup,0,0,0,0,1000,1000); 70 | } 71 | } 72 | 73 | @Override 74 | public void configureTraffic(TrafficShaping config) { 75 | this.trafficHandler.configure(config.getWriteLimit(),config.getReadLimit()); 76 | } 77 | 78 | @Override 79 | public ProxyDefinition getDefinition() { 80 | return definition; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/services/NettyServerService.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.services; 2 | 3 | import java.util.Set; 4 | 5 | import io.igx.proxy.domain.ConnectionStats; 6 | import io.igx.proxy.domain.CreateProxyRequest; 7 | import io.igx.proxy.domain.ProxyDefinition; 8 | import io.igx.proxy.domain.TrafficShaping; 9 | 10 | /** 11 | * @author Vinicius Carvalho 12 | */ 13 | public interface NettyServerService { 14 | ProxyDefinition createServer(CreateProxyRequest createProxyRequest); 15 | void startServer(String id); 16 | void stopServer(String id); 17 | ProxyDefinition getProxyDefinition(String id); 18 | Set listServers(); 19 | ConnectionStats getStats(String id); 20 | void configureTraffic(String id, TrafficShaping config); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/services/NettyServerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.services; 2 | 3 | import java.util.Map; 4 | import java.util.Set; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | import java.util.stream.Collectors; 7 | 8 | import javax.annotation.PreDestroy; 9 | 10 | import io.igx.proxy.domain.ConnectionStats; 11 | import io.igx.proxy.domain.CreateProxyRequest; 12 | import io.igx.proxy.domain.ProxyDefinition; 13 | import io.igx.proxy.domain.ServerNotFoundException; 14 | import io.igx.proxy.domain.TrafficShaping; 15 | import io.netty.channel.EventLoopGroup; 16 | import io.netty.channel.nio.NioEventLoopGroup; 17 | 18 | import org.springframework.stereotype.Service; 19 | 20 | /** 21 | * @author Vinicius Carvalho 22 | */ 23 | @Service 24 | public class NettyServerServiceImpl implements NettyServerService { 25 | 26 | private final EventLoopGroup bossGroup; 27 | private final EventLoopGroup workerGroup; 28 | private Map servers; 29 | 30 | public NettyServerServiceImpl(){ 31 | this.bossGroup = new NioEventLoopGroup(2); 32 | this.workerGroup = new NioEventLoopGroup(8); 33 | this.servers = new ConcurrentHashMap<>(); 34 | } 35 | 36 | 37 | @Override 38 | public ProxyDefinition createServer(CreateProxyRequest createProxyRequest){ 39 | 40 | ProxyDefinition proxyDefinition = new ProxyDefinition(createProxyRequest); 41 | if(!checkPortAvailable(proxyDefinition)){ 42 | throw new IllegalStateException("Selected local port already in use"); 43 | } 44 | servers.put(proxyDefinition.getId(),new TCPProxyServer(proxyDefinition)); 45 | return proxyDefinition; 46 | } 47 | 48 | @Override 49 | public void startServer(String id) { 50 | findServer(id).start(bossGroup,workerGroup); 51 | } 52 | 53 | @Override 54 | public void stopServer(String id) { 55 | findServer(id).stop(); 56 | } 57 | 58 | @Override 59 | public void configureTraffic(String id, TrafficShaping config) { 60 | ProxyServer server = findServer(id); 61 | server.getDefinition().getQos().setTrafficShaping(config); 62 | server.configureTraffic(config); 63 | } 64 | 65 | @Override 66 | public ProxyDefinition getProxyDefinition(String id) { 67 | return findServer(id).getDefinition(); 68 | } 69 | 70 | 71 | @Override 72 | public Set listServers(){ 73 | return servers.values().stream().map(p -> {return p.getDefinition();}).collect(Collectors.toSet()); 74 | } 75 | 76 | @Override 77 | public ConnectionStats getStats(String id) { 78 | return findServer(id).getStats(); 79 | } 80 | 81 | 82 | private ProxyServer findServer(String id){ 83 | ProxyServer server = servers.get(id); 84 | if(server == null) 85 | throw new ServerNotFoundException("Server not found: " + id); 86 | return server; 87 | } 88 | 89 | @PreDestroy 90 | public void shutdown(){ 91 | bossGroup.shutdownGracefully(); 92 | workerGroup.shutdownGracefully(); 93 | } 94 | 95 | /** 96 | * Check if there's already a proxy defined for this port. 97 | * @param proxyDefinition 98 | */ 99 | private boolean checkPortAvailable(ProxyDefinition proxyDefinition) { 100 | boolean portAvailble = true; 101 | 102 | for(Map.Entry entry : servers.entrySet()){ 103 | if(entry.getValue().getDefinition().getLocalPort().equals(proxyDefinition.getLocalPort())){ 104 | portAvailble = false; 105 | break; 106 | } 107 | } 108 | return portAvailble; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/services/ProxyServer.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.services; 2 | 3 | import io.igx.proxy.domain.ConnectionStats; 4 | import io.igx.proxy.domain.ProxyDefinition; 5 | import io.igx.proxy.domain.TrafficShaping; 6 | import io.netty.channel.EventLoopGroup; 7 | 8 | /** 9 | * @author Vinicius Carvalho 10 | */ 11 | public interface ProxyServer { 12 | ProxyDefinition getDefinition(); 13 | ConnectionStats getStats(); 14 | void start(EventLoopGroup bossGroup, EventLoopGroup workerGroup); 15 | void stop(); 16 | void configureTraffic(TrafficShaping config); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/io/igx/proxy/services/TCPProxyServer.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy.services; 2 | 3 | import io.igx.proxy.domain.ProxyDefinition; 4 | import io.igx.proxy.handlers.ProxyFrontendHandler; 5 | import io.igx.proxy.handlers.ProxyInitializer; 6 | import io.netty.bootstrap.ServerBootstrap; 7 | import io.netty.channel.Channel; 8 | import io.netty.channel.ChannelFuture; 9 | import io.netty.channel.ChannelOption; 10 | import io.netty.channel.EventLoopGroup; 11 | import io.netty.channel.socket.nio.NioServerSocketChannel; 12 | import io.netty.handler.logging.LogLevel; 13 | import io.netty.handler.logging.LoggingHandler; 14 | 15 | /** 16 | * @author Vinicius Carvalho 17 | */ 18 | public class TCPProxyServer extends AbstractProxyServer { 19 | 20 | public TCPProxyServer(ProxyDefinition definition) { 21 | super(definition); 22 | } 23 | 24 | @Override 25 | protected Channel doStart(EventLoopGroup bossGroup, EventLoopGroup workerGroup) { 26 | ServerBootstrap bootstrap = new ServerBootstrap(); 27 | final ProxyFrontendHandler frontendHandler = new ProxyFrontendHandler(definition); 28 | ChannelFuture cf = bootstrap.group(bossGroup,workerGroup) 29 | .option(ChannelOption.SO_REUSEADDR,false) 30 | .channel(NioServerSocketChannel.class) 31 | .handler(new LoggingHandler(LogLevel.INFO)) 32 | .childHandler(new ProxyInitializer(definition,trafficHandler)) 33 | .childOption(ChannelOption.AUTO_READ,true) 34 | .bind(definition.getLocalPort()); 35 | 36 | return cf.channel(); 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.io.netty=DEBUG -------------------------------------------------------------------------------- /src/main/resources/static/css/angular-chart.css: -------------------------------------------------------------------------------- 1 | .chart-legend, 2 | .bar-legend, 3 | .line-legend, 4 | .pie-legend, 5 | .radar-legend, 6 | .polararea-legend, 7 | .doughnut-legend { 8 | list-style-type: none; 9 | margin-top: 5px; 10 | text-align: center; 11 | /* NOTE: Browsers automatically add 40px of padding-left to all lists, so we should offset that, otherwise the legend is off-center */ 12 | -webkit-padding-start: 0; 13 | /* Webkit */ 14 | -moz-padding-start: 0; 15 | /* Mozilla */ 16 | padding-left: 0; 17 | /* IE (handles all cases, really, but we should also include the vendor-specific properties just to be safe) */ 18 | } 19 | .chart-legend li, 20 | .bar-legend li, 21 | .line-legend li, 22 | .pie-legend li, 23 | .radar-legend li, 24 | .polararea-legend li, 25 | .doughnut-legend li { 26 | display: inline-block; 27 | white-space: nowrap; 28 | position: relative; 29 | margin-bottom: 4px; 30 | border-radius: 5px; 31 | padding: 2px 8px 2px 28px; 32 | font-size: smaller; 33 | cursor: default; 34 | } 35 | .chart-legend-icon, 36 | .bar-legend-icon, 37 | .line-legend-icon, 38 | .pie-legend-icon, 39 | .radar-legend-icon, 40 | .polararea-legend-icon, 41 | .doughnut-legend-icon { 42 | display: block; 43 | position: absolute; 44 | left: 0; 45 | top: 0; 46 | width: 20px; 47 | height: 20px; 48 | border-radius: 5px; 49 | } 50 | -------------------------------------------------------------------------------- /src/main/resources/static/css/awesomeRating.css: -------------------------------------------------------------------------------- 1 | .rating-star { color: lightgrey; cursor: pointer; } 2 | .rating-star.fa-star { color: #FDD05B; } 3 | .rating-star-hover { opacity: 0.6; } 4 | .rating-star-fractional { position: absolute; overflow: hidden; z-index: 2; } -------------------------------------------------------------------------------- /src/main/resources/static/css/font-awesome.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.6.1 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.6.1');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.6.1') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.6.1') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.6.1') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.6.1') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.6.1#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-intersex:before,.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-genderless:before{content:"\f22d"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}.fa-yc:before,.fa-y-combinator:before{content:"\f23b"}.fa-optin-monster:before{content:"\f23c"}.fa-opencart:before{content:"\f23d"}.fa-expeditedssl:before{content:"\f23e"}.fa-battery-4:before,.fa-battery-full:before{content:"\f240"}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-battery-2:before,.fa-battery-half:before{content:"\f242"}.fa-battery-1:before,.fa-battery-quarter:before{content:"\f243"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-mouse-pointer:before{content:"\f245"}.fa-i-cursor:before{content:"\f246"}.fa-object-group:before{content:"\f247"}.fa-object-ungroup:before{content:"\f248"}.fa-sticky-note:before{content:"\f249"}.fa-sticky-note-o:before{content:"\f24a"}.fa-cc-jcb:before{content:"\f24b"}.fa-cc-diners-club:before{content:"\f24c"}.fa-clone:before{content:"\f24d"}.fa-balance-scale:before{content:"\f24e"}.fa-hourglass-o:before{content:"\f250"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-hourglass:before{content:"\f254"}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:"\f255"}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:"\f256"}.fa-hand-scissors-o:before{content:"\f257"}.fa-hand-lizard-o:before{content:"\f258"}.fa-hand-spock-o:before{content:"\f259"}.fa-hand-pointer-o:before{content:"\f25a"}.fa-hand-peace-o:before{content:"\f25b"}.fa-trademark:before{content:"\f25c"}.fa-registered:before{content:"\f25d"}.fa-creative-commons:before{content:"\f25e"}.fa-gg:before{content:"\f260"}.fa-gg-circle:before{content:"\f261"}.fa-tripadvisor:before{content:"\f262"}.fa-odnoklassniki:before{content:"\f263"}.fa-odnoklassniki-square:before{content:"\f264"}.fa-get-pocket:before{content:"\f265"}.fa-wikipedia-w:before{content:"\f266"}.fa-safari:before{content:"\f267"}.fa-chrome:before{content:"\f268"}.fa-firefox:before{content:"\f269"}.fa-opera:before{content:"\f26a"}.fa-internet-explorer:before{content:"\f26b"}.fa-tv:before,.fa-television:before{content:"\f26c"}.fa-contao:before{content:"\f26d"}.fa-500px:before{content:"\f26e"}.fa-amazon:before{content:"\f270"}.fa-calendar-plus-o:before{content:"\f271"}.fa-calendar-minus-o:before{content:"\f272"}.fa-calendar-times-o:before{content:"\f273"}.fa-calendar-check-o:before{content:"\f274"}.fa-industry:before{content:"\f275"}.fa-map-pin:before{content:"\f276"}.fa-map-signs:before{content:"\f277"}.fa-map-o:before{content:"\f278"}.fa-map:before{content:"\f279"}.fa-commenting:before{content:"\f27a"}.fa-commenting-o:before{content:"\f27b"}.fa-houzz:before{content:"\f27c"}.fa-vimeo:before{content:"\f27d"}.fa-black-tie:before{content:"\f27e"}.fa-fonticons:before{content:"\f280"}.fa-reddit-alien:before{content:"\f281"}.fa-edge:before{content:"\f282"}.fa-credit-card-alt:before{content:"\f283"}.fa-codiepie:before{content:"\f284"}.fa-modx:before{content:"\f285"}.fa-fort-awesome:before{content:"\f286"}.fa-usb:before{content:"\f287"}.fa-product-hunt:before{content:"\f288"}.fa-mixcloud:before{content:"\f289"}.fa-scribd:before{content:"\f28a"}.fa-pause-circle:before{content:"\f28b"}.fa-pause-circle-o:before{content:"\f28c"}.fa-stop-circle:before{content:"\f28d"}.fa-stop-circle-o:before{content:"\f28e"}.fa-shopping-bag:before{content:"\f290"}.fa-shopping-basket:before{content:"\f291"}.fa-hashtag:before{content:"\f292"}.fa-bluetooth:before{content:"\f293"}.fa-bluetooth-b:before{content:"\f294"}.fa-percent:before{content:"\f295"}.fa-gitlab:before{content:"\f296"}.fa-wpbeginner:before{content:"\f297"}.fa-wpforms:before{content:"\f298"}.fa-envira:before{content:"\f299"}.fa-universal-access:before{content:"\f29a"}.fa-wheelchair-alt:before{content:"\f29b"}.fa-question-circle-o:before{content:"\f29c"}.fa-blind:before{content:"\f29d"}.fa-audio-description:before{content:"\f29e"}.fa-volume-control-phone:before{content:"\f2a0"}.fa-braille:before{content:"\f2a1"}.fa-assistive-listening-systems:before{content:"\f2a2"}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:"\f2a3"}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:"\f2a4"}.fa-glide:before{content:"\f2a5"}.fa-glide-g:before{content:"\f2a6"}.fa-signing:before,.fa-sign-language:before{content:"\f2a7"}.fa-low-vision:before{content:"\f2a8"}.fa-viadeo:before{content:"\f2a9"}.fa-viadeo-square:before{content:"\f2aa"}.fa-snapchat:before{content:"\f2ab"}.fa-snapchat-ghost:before{content:"\f2ac"}.fa-snapchat-square:before{content:"\f2ad"}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto} -------------------------------------------------------------------------------- /src/main/resources/static/css/tcpproxy.css: -------------------------------------------------------------------------------- 1 | 2 | html { 3 | position: relative; 4 | min-height: 100%; 5 | } 6 | 7 | 8 | body { 9 | margin-bottom: 60px; 10 | } 11 | 12 | body, h1, h2, h3 { 13 | font-weight: 400; 14 | font-family: "Varela Round", sans-serif; 15 | background-color: #5d5d5d; 16 | } 17 | 18 | 19 | .navbar { 20 | border-top: 4px solid #6db33f; 21 | background-color: #34302d; 22 | border-radius: 0px; 23 | margin-bottom: 0px; 24 | border-bottom: 0; 25 | border-left: 0; 26 | border-right: 0; 27 | } 28 | 29 | 30 | a:link, 31 | a:hover, 32 | a:active, 33 | a:visited { 34 | -webkit-transition: color 150ms; 35 | transition: color 150ms; 36 | color: #95a5a6; 37 | text-decoration: none; 38 | } 39 | a:hover { 40 | color: #7f8c8d; 41 | text-decoration: underline; 42 | } 43 | .contain { 44 | width: 100%; 45 | } 46 | 47 | .footer { 48 | font-size: 4px; 49 | position: relative; 50 | margin-top: -100px; /* negative value of footer height */ 51 | height: 100px; 52 | clear:both; 53 | padding-top:20px; 54 | } 55 | .ps { 56 | background-color: gray; 57 | } -------------------------------------------------------------------------------- /src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/static/fonts/material-design-icons/LICENSE.txt: -------------------------------------------------------------------------------- 1 | https://github.com/google/material-design-icons/blob/master/LICENSE 2 | https://github.com/FezVrasta/bootstrap-material-design/blob/master/fonts/LICENSE.txt 3 | 4 | Attribution-ShareAlike 4.0 International 5 | 6 | ======================================================================= 7 | 8 | Creative Commons Corporation ("Creative Commons") is not a law firm and 9 | does not provide legal services or legal advice. Distribution of 10 | Creative Commons public licenses does not create a lawyer-client or 11 | other relationship. Creative Commons makes its licenses and related 12 | information available on an "as-is" basis. Creative Commons gives no 13 | warranties regarding its licenses, any material licensed under their 14 | terms and conditions, or any related information. Creative Commons 15 | disclaims all liability for damages resulting from their use to the 16 | fullest extent possible. 17 | 18 | Using Creative Commons Public Licenses 19 | 20 | Creative Commons public licenses provide a standard set of terms and 21 | conditions that creators and other rights holders may use to share 22 | original works of authorship and other material subject to copyright 23 | and certain other rights specified in the public license below. The 24 | following considerations are for informational purposes only, are not 25 | exhaustive, and do not form part of our licenses. 26 | 27 | Considerations for licensors: Our public licenses are 28 | intended for use by those authorized to give the public 29 | permission to use material in ways otherwise restricted by 30 | copyright and certain other rights. Our licenses are 31 | irrevocable. Licensors should read and understand the terms 32 | and conditions of the license they choose before applying it. 33 | Licensors should also secure all rights necessary before 34 | applying our licenses so that the public can reuse the 35 | material as expected. Licensors should clearly mark any 36 | material not subject to the license. This includes other CC- 37 | licensed material, or material used under an exception or 38 | limitation to copyright. More considerations for licensors: 39 | wiki.creativecommons.org/Considerations_for_licensors 40 | 41 | Considerations for the public: By using one of our public 42 | licenses, a licensor grants the public permission to use the 43 | licensed material under specified terms and conditions. If 44 | the licensor's permission is not necessary for any reason--for 45 | example, because of any applicable exception or limitation to 46 | copyright--then that use is not regulated by the license. Our 47 | licenses grant only permissions under copyright and certain 48 | other rights that a licensor has authority to grant. Use of 49 | the licensed material may still be restricted for other 50 | reasons, including because others have copyright or other 51 | rights in the material. A licensor may make special requests, 52 | such as asking that all changes be marked or described. 53 | Although not required by our licenses, you are encouraged to 54 | respect those requests where reasonable. More_considerations 55 | for the public: 56 | wiki.creativecommons.org/Considerations_for_licensees 57 | 58 | ======================================================================= 59 | 60 | Creative Commons Attribution-ShareAlike 4.0 International Public 61 | License 62 | 63 | By exercising the Licensed Rights (defined below), You accept and agree 64 | to be bound by the terms and conditions of this Creative Commons 65 | Attribution-ShareAlike 4.0 International Public License ("Public 66 | License"). To the extent this Public License may be interpreted as a 67 | contract, You are granted the Licensed Rights in consideration of Your 68 | acceptance of these terms and conditions, and the Licensor grants You 69 | such rights in consideration of benefits the Licensor receives from 70 | making the Licensed Material available under these terms and 71 | conditions. 72 | 73 | 74 | Section 1 -- Definitions. 75 | 76 | a. Adapted Material means material subject to Copyright and Similar 77 | Rights that is derived from or based upon the Licensed Material 78 | and in which the Licensed Material is translated, altered, 79 | arranged, transformed, or otherwise modified in a manner requiring 80 | permission under the Copyright and Similar Rights held by the 81 | Licensor. For purposes of this Public License, where the Licensed 82 | Material is a musical work, performance, or sound recording, 83 | Adapted Material is always produced where the Licensed Material is 84 | synched in timed relation with a moving image. 85 | 86 | b. Adapter's License means the license You apply to Your Copyright 87 | and Similar Rights in Your contributions to Adapted Material in 88 | accordance with the terms and conditions of this Public License. 89 | 90 | c. BY-SA Compatible License means a license listed at 91 | creativecommons.org/compatiblelicenses, approved by Creative 92 | Commons as essentially the equivalent of this Public License. 93 | 94 | d. Copyright and Similar Rights means copyright and/or similar rights 95 | closely related to copyright including, without limitation, 96 | performance, broadcast, sound recording, and Sui Generis Database 97 | Rights, without regard to how the rights are labeled or 98 | categorized. For purposes of this Public License, the rights 99 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 100 | Rights. 101 | 102 | e. Effective Technological Measures means those measures that, in the 103 | absence of proper authority, may not be circumvented under laws 104 | fulfilling obligations under Article 11 of the WIPO Copyright 105 | Treaty adopted on December 20, 1996, and/or similar international 106 | agreements. 107 | 108 | f. Exceptions and Limitations means fair use, fair dealing, and/or 109 | any other exception or limitation to Copyright and Similar Rights 110 | that applies to Your use of the Licensed Material. 111 | 112 | g. License Elements means the license attributes listed in the name 113 | of a Creative Commons Public License. The License Elements of this 114 | Public License are Attribution and ShareAlike. 115 | 116 | h. Licensed Material means the artistic or literary work, database, 117 | or other material to which the Licensor applied this Public 118 | License. 119 | 120 | i. Licensed Rights means the rights granted to You subject to the 121 | terms and conditions of this Public License, which are limited to 122 | all Copyright and Similar Rights that apply to Your use of the 123 | Licensed Material and that the Licensor has authority to license. 124 | 125 | j. Licensor means the individual(s) or entity(ies) granting rights 126 | under this Public License. 127 | 128 | k. Share means to provide material to the public by any means or 129 | process that requires permission under the Licensed Rights, such 130 | as reproduction, public display, public performance, distribution, 131 | dissemination, communication, or importation, and to make material 132 | available to the public including in ways that members of the 133 | public may access the material from a place and at a time 134 | individually chosen by them. 135 | 136 | l. Sui Generis Database Rights means rights other than copyright 137 | resulting from Directive 96/9/EC of the European Parliament and of 138 | the Council of 11 March 1996 on the legal protection of databases, 139 | as amended and/or succeeded, as well as other essentially 140 | equivalent rights anywhere in the world. 141 | 142 | m. You means the individual or entity exercising the Licensed Rights 143 | under this Public License. Your has a corresponding meaning. 144 | 145 | 146 | Section 2 -- Scope. 147 | 148 | a. License grant. 149 | 150 | 1. Subject to the terms and conditions of this Public License, 151 | the Licensor hereby grants You a worldwide, royalty-free, 152 | non-sublicensable, non-exclusive, irrevocable license to 153 | exercise the Licensed Rights in the Licensed Material to: 154 | 155 | a. reproduce and Share the Licensed Material, in whole or 156 | in part; and 157 | 158 | b. produce, reproduce, and Share Adapted Material. 159 | 160 | 2. Exceptions and Limitations. For the avoidance of doubt, where 161 | Exceptions and Limitations apply to Your use, this Public 162 | License does not apply, and You do not need to comply with 163 | its terms and conditions. 164 | 165 | 3. Term. The term of this Public License is specified in Section 166 | 6(a). 167 | 168 | 4. Media and formats; technical modifications allowed. The 169 | Licensor authorizes You to exercise the Licensed Rights in 170 | all media and formats whether now known or hereafter created, 171 | and to make technical modifications necessary to do so. The 172 | Licensor waives and/or agrees not to assert any right or 173 | authority to forbid You from making technical modifications 174 | necessary to exercise the Licensed Rights, including 175 | technical modifications necessary to circumvent Effective 176 | Technological Measures. For purposes of this Public License, 177 | simply making modifications authorized by this Section 2(a) 178 | (4) never produces Adapted Material. 179 | 180 | 5. Downstream recipients. 181 | 182 | a. Offer from the Licensor -- Licensed Material. Every 183 | recipient of the Licensed Material automatically 184 | receives an offer from the Licensor to exercise the 185 | Licensed Rights under the terms and conditions of this 186 | Public License. 187 | 188 | b. Additional offer from the Licensor -- Adapted Material. 189 | Every recipient of Adapted Material from You 190 | automatically receives an offer from the Licensor to 191 | exercise the Licensed Rights in the Adapted Material 192 | under the conditions of the Adapter's License You apply. 193 | 194 | c. No downstream restrictions. You may not offer or impose 195 | any additional or different terms or conditions on, or 196 | apply any Effective Technological Measures to, the 197 | Licensed Material if doing so restricts exercise of the 198 | Licensed Rights by any recipient of the Licensed 199 | Material. 200 | 201 | 6. No endorsement. Nothing in this Public License constitutes or 202 | may be construed as permission to assert or imply that You 203 | are, or that Your use of the Licensed Material is, connected 204 | with, or sponsored, endorsed, or granted official status by, 205 | the Licensor or others designated to receive attribution as 206 | provided in Section 3(a)(1)(A)(i). 207 | 208 | b. Other rights. 209 | 210 | 1. Moral rights, such as the right of integrity, are not 211 | licensed under this Public License, nor are publicity, 212 | privacy, and/or other similar personality rights; however, to 213 | the extent possible, the Licensor waives and/or agrees not to 214 | assert any such rights held by the Licensor to the limited 215 | extent necessary to allow You to exercise the Licensed 216 | Rights, but not otherwise. 217 | 218 | 2. Patent and trademark rights are not licensed under this 219 | Public License. 220 | 221 | 3. To the extent possible, the Licensor waives any right to 222 | collect royalties from You for the exercise of the Licensed 223 | Rights, whether directly or through a collecting society 224 | under any voluntary or waivable statutory or compulsory 225 | licensing scheme. In all other cases the Licensor expressly 226 | reserves any right to collect such royalties. 227 | 228 | 229 | Section 3 -- License Conditions. 230 | 231 | Your exercise of the Licensed Rights is expressly made subject to the 232 | following conditions. 233 | 234 | a. Attribution. 235 | 236 | 1. If You Share the Licensed Material (including in modified 237 | form), You must: 238 | 239 | a. retain the following if it is supplied by the Licensor 240 | with the Licensed Material: 241 | 242 | i. identification of the creator(s) of the Licensed 243 | Material and any others designated to receive 244 | attribution, in any reasonable manner requested by 245 | the Licensor (including by pseudonym if 246 | designated); 247 | 248 | ii. a copyright notice; 249 | 250 | iii. a notice that refers to this Public License; 251 | 252 | iv. a notice that refers to the disclaimer of 253 | warranties; 254 | 255 | v. a URI or hyperlink to the Licensed Material to the 256 | extent reasonably practicable; 257 | 258 | b. indicate if You modified the Licensed Material and 259 | retain an indication of any previous modifications; and 260 | 261 | c. indicate the Licensed Material is licensed under this 262 | Public License, and include the text of, or the URI or 263 | hyperlink to, this Public License. 264 | 265 | 2. You may satisfy the conditions in Section 3(a)(1) in any 266 | reasonable manner based on the medium, means, and context in 267 | which You Share the Licensed Material. For example, it may be 268 | reasonable to satisfy the conditions by providing a URI or 269 | hyperlink to a resource that includes the required 270 | information. 271 | 272 | 3. If requested by the Licensor, You must remove any of the 273 | information required by Section 3(a)(1)(A) to the extent 274 | reasonably practicable. 275 | 276 | b. ShareAlike. 277 | 278 | In addition to the conditions in Section 3(a), if You Share 279 | Adapted Material You produce, the following conditions also apply. 280 | 281 | 1. The Adapter's License You apply must be a Creative Commons 282 | license with the same License Elements, this version or 283 | later, or a BY-SA Compatible License. 284 | 285 | 2. You must include the text of, or the URI or hyperlink to, the 286 | Adapter's License You apply. You may satisfy this condition 287 | in any reasonable manner based on the medium, means, and 288 | context in which You Share Adapted Material. 289 | 290 | 3. You may not offer or impose any additional or different terms 291 | or conditions on, or apply any Effective Technological 292 | Measures to, Adapted Material that restrict exercise of the 293 | rights granted under the Adapter's License You apply. 294 | 295 | 296 | Section 4 -- Sui Generis Database Rights. 297 | 298 | Where the Licensed Rights include Sui Generis Database Rights that 299 | apply to Your use of the Licensed Material: 300 | 301 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 302 | to extract, reuse, reproduce, and Share all or a substantial 303 | portion of the contents of the database; 304 | 305 | b. if You include all or a substantial portion of the database 306 | contents in a database in which You have Sui Generis Database 307 | Rights, then the database in which You have Sui Generis Database 308 | Rights (but not its individual contents) is Adapted Material, 309 | 310 | including for purposes of Section 3(b); and 311 | c. You must comply with the conditions in Section 3(a) if You Share 312 | all or a substantial portion of the contents of the database. 313 | 314 | For the avoidance of doubt, this Section 4 supplements and does not 315 | replace Your obligations under this Public License where the Licensed 316 | Rights include other Copyright and Similar Rights. 317 | 318 | 319 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 320 | 321 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 322 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 323 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 324 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 325 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 326 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 327 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 328 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 329 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 330 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 331 | 332 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 333 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 334 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 335 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 336 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 337 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 338 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 339 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 340 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 341 | 342 | c. The disclaimer of warranties and limitation of liability provided 343 | above shall be interpreted in a manner that, to the extent 344 | possible, most closely approximates an absolute disclaimer and 345 | waiver of all liability. 346 | 347 | 348 | Section 6 -- Term and Termination. 349 | 350 | a. This Public License applies for the term of the Copyright and 351 | Similar Rights licensed here. However, if You fail to comply with 352 | this Public License, then Your rights under this Public License 353 | terminate automatically. 354 | 355 | b. Where Your right to use the Licensed Material has terminated under 356 | Section 6(a), it reinstates: 357 | 358 | 1. automatically as of the date the violation is cured, provided 359 | it is cured within 30 days of Your discovery of the 360 | violation; or 361 | 362 | 2. upon express reinstatement by the Licensor. 363 | 364 | For the avoidance of doubt, this Section 6(b) does not affect any 365 | right the Licensor may have to seek remedies for Your violations 366 | of this Public License. 367 | 368 | c. For the avoidance of doubt, the Licensor may also offer the 369 | Licensed Material under separate terms or conditions or stop 370 | distributing the Licensed Material at any time; however, doing so 371 | will not terminate this Public License. 372 | 373 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 374 | License. 375 | 376 | 377 | Section 7 -- Other Terms and Conditions. 378 | 379 | a. The Licensor shall not be bound by any additional or different 380 | terms or conditions communicated by You unless expressly agreed. 381 | 382 | b. Any arrangements, understandings, or agreements regarding the 383 | Licensed Material not stated herein are separate from and 384 | independent of the terms and conditions of this Public License. 385 | 386 | 387 | Section 8 -- Interpretation. 388 | 389 | a. For the avoidance of doubt, this Public License does not, and 390 | shall not be interpreted to, reduce, limit, restrict, or impose 391 | conditions on any use of the Licensed Material that could lawfully 392 | be made without permission under this Public License. 393 | 394 | b. To the extent possible, if any provision of this Public License is 395 | deemed unenforceable, it shall be automatically reformed to the 396 | minimum extent necessary to make it enforceable. If the provision 397 | cannot be reformed, it shall be severed from this Public License 398 | without affecting the enforceability of the remaining terms and 399 | conditions. 400 | 401 | c. No term or condition of this Public License will be waived and no 402 | failure to comply consented to unless expressly agreed to by the 403 | Licensor. 404 | 405 | d. Nothing in this Public License constitutes or may be interpreted 406 | as a limitation upon, or waiver of, any privileges and immunities 407 | that apply to the Licensor or You, including from the legal 408 | processes of any jurisdiction or authority. 409 | 410 | 411 | ======================================================================= 412 | 413 | Creative Commons is not a party to its public licenses. 414 | Notwithstanding, Creative Commons may elect to apply one of its public 415 | licenses to material it publishes and in those instances will be 416 | considered the "Licensor." Except for the limited purpose of indicating 417 | that material is shared under a Creative Commons public license or as 418 | otherwise permitted by the Creative Commons policies published at 419 | creativecommons.org/policies, Creative Commons does not authorize the 420 | use of the trademark "Creative Commons" or any other trademark or logo 421 | of Creative Commons without its prior written consent including, 422 | without limitation, in connection with any unauthorized modifications 423 | to any of its public licenses or any other arrangements, 424 | understandings, or agreements concerning use of licensed material. For 425 | the avoidance of doubt, this paragraph does not form part of the public 426 | licenses. 427 | 428 | Creative Commons may be contacted at creativecommons.org. 429 | -------------------------------------------------------------------------------- /src/main/resources/static/fonts/material-design-icons/Material-Design-Icons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/material-design-icons/Material-Design-Icons.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/material-design-icons/Material-Design-Icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/material-design-icons/Material-Design-Icons.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/material-design-icons/Material-Design-Icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/material-design-icons/Material-Design-Icons.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/material-design-icons/Material-Design-Icons.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/material-design-icons/Material-Design-Icons.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Bold.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Bold.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Bold.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Bold.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Light.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Light.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Light.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Light.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Light.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Light.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Medium.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Medium.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Medium.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Medium.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Medium.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Medium.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Medium.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Regular.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Regular.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Regular.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Regular.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Thin.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Thin.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Thin.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Thin.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Thin.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/roboto/Roboto-Thin.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/fonts/roboto/Roboto-Thin.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/images/off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/images/off.png -------------------------------------------------------------------------------- /src/main/resources/static/images/on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viniciusccarvalho/nano-proxy/ef3d0ca05b284578289a17d7a4576d59f1763aa7/src/main/resources/static/images/on.png -------------------------------------------------------------------------------- /src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Nano Proxy 6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | 26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/resources/static/js/angular-chart.js: -------------------------------------------------------------------------------- 1 | (function (factory) { 2 | 'use strict'; 3 | if (typeof exports === 'object') { 4 | // Node/CommonJS 5 | module.exports = factory( 6 | typeof angular !== 'undefined' ? angular : require('angular'), 7 | typeof Chart !== 'undefined' ? Chart : require('chart.js')); 8 | } else if (typeof define === 'function' && define.amd) { 9 | // AMD. Register as an anonymous module. 10 | define(['angular', 'chart'], factory); 11 | } else { 12 | // Browser globals 13 | factory(angular, Chart); 14 | } 15 | }(function (angular, Chart) { 16 | 'use strict'; 17 | 18 | Chart.defaults.global.responsive = true; 19 | Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>'; 20 | 21 | Chart.defaults.global.colours = [ 22 | '#97BBCD', // blue 23 | '#DCDCDC', // light grey 24 | '#F7464A', // red 25 | '#46BFBD', // green 26 | '#FDB45C', // yellow 27 | '#949FB1', // grey 28 | '#4D5360' // dark grey 29 | ]; 30 | 31 | var usingExcanvas = typeof window.G_vmlCanvasManager === 'object' && 32 | window.G_vmlCanvasManager !== null && 33 | typeof window.G_vmlCanvasManager.initElement === 'function'; 34 | 35 | if (usingExcanvas) Chart.defaults.global.animation = false; 36 | 37 | return angular.module('chart.js', []) 38 | .provider('ChartJs', ChartJsProvider) 39 | .factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory]) 40 | .directive('chartBase', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory(); }]) 41 | .directive('chartLine', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Line'); }]) 42 | .directive('chartBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Bar'); }]) 43 | .directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Radar'); }]) 44 | .directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Doughnut'); }]) 45 | .directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Pie'); }]) 46 | .directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('PolarArea'); }]); 47 | 48 | /** 49 | * Wrapper for chart.js 50 | * Allows configuring chart js using the provider 51 | * 52 | * angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) { 53 | * ChartJsProvider.setOptions({ responsive: true }); 54 | * ChartJsProvider.setOptions('Line', { responsive: false }); 55 | * }))) 56 | */ 57 | function ChartJsProvider () { 58 | var options = {}; 59 | var ChartJs = { 60 | Chart: Chart, 61 | getOptions: function (type) { 62 | var typeOptions = type && options[type] || {}; 63 | return angular.extend({}, options, typeOptions); 64 | } 65 | }; 66 | 67 | /** 68 | * Allow to set global options during configuration 69 | */ 70 | this.setOptions = function (type, customOptions) { 71 | // If no type was specified set option for the global object 72 | if (! customOptions) { 73 | customOptions = type; 74 | options = angular.extend(options, customOptions); 75 | return; 76 | } 77 | // Set options for the specific chart 78 | options[type] = angular.extend(options[type] || {}, customOptions); 79 | }; 80 | 81 | this.$get = function () { 82 | return ChartJs; 83 | }; 84 | } 85 | 86 | function ChartJsFactory (ChartJs, $timeout) { 87 | return function chart (type) { 88 | return { 89 | restrict: 'CA', 90 | scope: { 91 | data: '=?', 92 | labels: '=?', 93 | options: '=?', 94 | series: '=?', 95 | colours: '=?', 96 | getColour: '=?', 97 | chartType: '=', 98 | legend: '@', 99 | click: '=?', 100 | hover: '=?', 101 | 102 | chartData: '=?', 103 | chartLabels: '=?', 104 | chartOptions: '=?', 105 | chartSeries: '=?', 106 | chartColours: '=?', 107 | chartLegend: '@', 108 | chartClick: '=?', 109 | chartHover: '=?' 110 | }, 111 | link: function (scope, elem/*, attrs */) { 112 | var chart, container = document.createElement('div'); 113 | container.className = 'chart-container'; 114 | elem.replaceWith(container); 115 | container.appendChild(elem[0]); 116 | 117 | if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]); 118 | 119 | ['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated); 120 | function aliasVar (fromName, toName) { 121 | scope.$watch(fromName, function (newVal) { 122 | if (typeof newVal === 'undefined') return; 123 | scope[toName] = newVal; 124 | }); 125 | } 126 | /* provide backward compatibility to "old" directive names, by 127 | * having an alias point from the new names to the old names. */ 128 | aliasVar('chartData', 'data'); 129 | aliasVar('chartLabels', 'labels'); 130 | aliasVar('chartOptions', 'options'); 131 | aliasVar('chartSeries', 'series'); 132 | aliasVar('chartColours', 'colours'); 133 | aliasVar('chartLegend', 'legend'); 134 | aliasVar('chartClick', 'click'); 135 | aliasVar('chartHover', 'hover'); 136 | 137 | // Order of setting "watch" matter 138 | 139 | scope.$watch('data', function (newVal, oldVal) { 140 | if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) { 141 | destroyChart(chart, scope); 142 | return; 143 | } 144 | var chartType = type || scope.chartType; 145 | if (! chartType) return; 146 | 147 | if (chart && canUpdateChart(newVal, oldVal)) 148 | return updateChart(chart, newVal, scope, elem); 149 | 150 | createChart(chartType); 151 | }, true); 152 | 153 | scope.$watch('series', resetChart, true); 154 | scope.$watch('labels', resetChart, true); 155 | scope.$watch('options', resetChart, true); 156 | scope.$watch('colours', resetChart, true); 157 | 158 | scope.$watch('chartType', function (newVal, oldVal) { 159 | if (isEmpty(newVal)) return; 160 | if (angular.equals(newVal, oldVal)) return; 161 | createChart(newVal); 162 | }); 163 | 164 | scope.$on('$destroy', function () { 165 | destroyChart(chart, scope); 166 | }); 167 | 168 | function resetChart (newVal, oldVal) { 169 | if (isEmpty(newVal)) return; 170 | if (angular.equals(newVal, oldVal)) return; 171 | var chartType = type || scope.chartType; 172 | if (! chartType) return; 173 | 174 | // chart.update() doesn't work for series and labels 175 | // so we have to re-create the chart entirely 176 | createChart(chartType); 177 | } 178 | 179 | function createChart (type) { 180 | if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) { 181 | return $timeout(function () { 182 | createChart(type); 183 | }, 50, false); 184 | } 185 | if (! scope.data || ! scope.data.length) return; 186 | scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour; 187 | var colours = getColours(type, scope); 188 | var cvs = elem[0], ctx = cvs.getContext('2d'); 189 | var data = Array.isArray(scope.data[0]) ? 190 | getDataSets(scope.labels, scope.data, scope.series || [], colours) : 191 | getData(scope.labels, scope.data, colours); 192 | var options = angular.extend({}, ChartJs.getOptions(type), scope.options); 193 | 194 | // Destroy old chart if it exists to avoid ghost charts issue 195 | // https://github.com/jtblin/angular-chart.js/issues/187 196 | destroyChart(chart, scope); 197 | chart = new ChartJs.Chart(ctx)[type](data, options); 198 | scope.$emit('create', chart); 199 | 200 | // Bind events 201 | cvs.onclick = scope.click ? getEventHandler(scope, chart, 'click', false) : angular.noop; 202 | cvs.onmousemove = scope.hover ? getEventHandler(scope, chart, 'hover', true) : angular.noop; 203 | 204 | if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); 205 | } 206 | 207 | function deprecated (attr) { 208 | if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') { 209 | var warn = typeof console.warn === 'function' ? console.warn : console.log; 210 | if (!! scope[attr]) { 211 | warn.call(console, '"%s" is deprecated and will be removed in a future version. ' + 212 | 'Please use "chart-%s" instead.', attr, attr); 213 | } 214 | } 215 | } 216 | } 217 | }; 218 | }; 219 | 220 | function canUpdateChart (newVal, oldVal) { 221 | if (newVal && oldVal && newVal.length && oldVal.length) { 222 | return Array.isArray(newVal[0]) ? 223 | newVal.length === oldVal.length && newVal.every(function (element, index) { 224 | return element.length === oldVal[index].length; }) : 225 | oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false; 226 | } 227 | return false; 228 | } 229 | 230 | function sum (carry, val) { 231 | return carry + val; 232 | } 233 | 234 | function getEventHandler (scope, chart, action, triggerOnlyOnChange) { 235 | var lastState = null; 236 | return function (evt) { 237 | var atEvent = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent; 238 | if (atEvent) { 239 | var activePoints = atEvent.call(chart, evt); 240 | if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) { 241 | lastState = activePoints; 242 | scope[action](activePoints, evt); 243 | scope.$apply(); 244 | } 245 | } 246 | }; 247 | } 248 | 249 | function getColours (type, scope) { 250 | var notEnoughColours = false; 251 | var colours = angular.copy(scope.colours || 252 | ChartJs.getOptions(type).colours || 253 | Chart.defaults.global.colours 254 | ); 255 | while (colours.length < scope.data.length) { 256 | colours.push(scope.getColour()); 257 | notEnoughColours = true; 258 | } 259 | // mutate colours in this case as we don't want 260 | // the colours to change on each refresh 261 | if (notEnoughColours) scope.colours = colours; 262 | return colours.map(convertColour); 263 | } 264 | 265 | function convertColour (colour) { 266 | if (typeof colour === 'object' && colour !== null) return colour; 267 | if (typeof colour === 'string' && colour[0] === '#') return getColour(hexToRgb(colour.substr(1))); 268 | return getRandomColour(); 269 | } 270 | 271 | function getRandomColour () { 272 | var colour = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)]; 273 | return getColour(colour); 274 | } 275 | 276 | function getColour (colour) { 277 | return { 278 | fillColor: rgba(colour, 0.2), 279 | strokeColor: rgba(colour, 1), 280 | pointColor: rgba(colour, 1), 281 | pointStrokeColor: '#fff', 282 | pointHighlightFill: '#fff', 283 | pointHighlightStroke: rgba(colour, 0.8) 284 | }; 285 | } 286 | 287 | function getRandomInt (min, max) { 288 | return Math.floor(Math.random() * (max - min + 1)) + min; 289 | } 290 | 291 | function rgba (colour, alpha) { 292 | if (usingExcanvas) { 293 | // rgba not supported by IE8 294 | return 'rgb(' + colour.join(',') + ')'; 295 | } else { 296 | return 'rgba(' + colour.concat(alpha).join(',') + ')'; 297 | } 298 | } 299 | 300 | // Credit: http://stackoverflow.com/a/11508164/1190235 301 | function hexToRgb (hex) { 302 | var bigint = parseInt(hex, 16), 303 | r = (bigint >> 16) & 255, 304 | g = (bigint >> 8) & 255, 305 | b = bigint & 255; 306 | 307 | return [r, g, b]; 308 | } 309 | 310 | function getDataSets (labels, data, series, colours) { 311 | return { 312 | labels: labels, 313 | datasets: data.map(function (item, i) { 314 | return angular.extend({}, colours[i], { 315 | label: series[i], 316 | data: item 317 | }); 318 | }) 319 | }; 320 | } 321 | 322 | function getData (labels, data, colours) { 323 | return labels.map(function (label, i) { 324 | return angular.extend({}, colours[i], { 325 | label: label, 326 | value: data[i], 327 | color: colours[i].strokeColor, 328 | highlight: colours[i].pointHighlightStroke 329 | }); 330 | }); 331 | } 332 | 333 | function setLegend (elem, chart) { 334 | var $parent = elem.parent(), 335 | $oldLegend = $parent.find('chart-legend'), 336 | legend = '' + chart.generateLegend() + ''; 337 | if ($oldLegend.length) $oldLegend.replaceWith(legend); 338 | else $parent.append(legend); 339 | } 340 | 341 | function updateChart (chart, values, scope, elem) { 342 | if (Array.isArray(scope.data[0])) { 343 | chart.datasets.forEach(function (dataset, i) { 344 | (dataset.points || dataset.bars).forEach(function (dataItem, j) { 345 | dataItem.value = values[i][j]; 346 | }); 347 | }); 348 | } else { 349 | chart.segments.forEach(function (segment, i) { 350 | segment.value = values[i]; 351 | }); 352 | } 353 | chart.update(); 354 | scope.$emit('update', chart); 355 | if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); 356 | } 357 | 358 | function isEmpty (value) { 359 | return ! value || 360 | (Array.isArray(value) && ! value.length) || 361 | (typeof value === 'object' && ! Object.keys(value).length); 362 | } 363 | 364 | function isResponsive (type, scope) { 365 | var options = angular.extend({}, Chart.defaults.global, ChartJs.getOptions(type), scope.options); 366 | return options.responsive; 367 | } 368 | 369 | function destroyChart(chart, scope) { 370 | if(! chart) return; 371 | chart.destroy(); 372 | scope.$emit('destroy', chart); 373 | } 374 | } 375 | })); 376 | -------------------------------------------------------------------------------- /src/main/resources/static/js/angular-chart.min.js: -------------------------------------------------------------------------------- 1 | !function(t){"use strict";"object"==typeof exports?module.exports=t("undefined"!=typeof angular?angular:require("angular"),"undefined"!=typeof Chart?Chart:require("chart.js")):"function"==typeof define&&define.amd?define(["angular","chart"],t):t(angular,Chart)}(function(t,e){"use strict";function n(){var n={},r={Chart:e,getOptions:function(e){var r=e&&n[e]||{};return t.extend({},n,r)}};this.setOptions=function(e,r){return r?void(n[e]=t.extend(n[e]||{},r)):(r=e,void(n=t.extend(n,r)))},this.$get=function(){return r}}function r(n,r){function o(t,e){return t&&e&&t.length&&e.length?Array.isArray(t[0])?t.length===e.length&&t.every(function(t,n){return t.length===e[n].length}):e.reduce(i,0)>0?t.length===e.length:!1:!1}function i(t,e){return t+e}function c(e,n,r,a){var o=null;return function(i){var c=n.getPointsAtEvent||n.getBarsAtEvent||n.getSegmentsAtEvent;if(c){var l=c.call(n,i);a!==!1&&t.equals(o,l)!==!1||(o=l,e[r](l,i),e.$apply())}}}function l(r,a){for(var o=!1,i=t.copy(a.colours||n.getOptions(r).colours||e.defaults.global.colours);i.length>16&255,r=e>>8&255,a=255&e;return[n,r,a]}function p(e,n,r,a){return{labels:e,datasets:n.map(function(e,n){return t.extend({},a[n],{label:r[n],data:e})})}}function v(e,n,r){return e.map(function(e,a){return t.extend({},r[a],{label:e,value:n[a],color:r[a].strokeColor,highlight:r[a].pointHighlightStroke})})}function y(t,e){var n=t.parent(),r=n.find("chart-legend"),a=""+e.generateLegend()+"";r.length?r.replaceWith(a):n.append(a)}function C(t,e,n,r){Array.isArray(n.data[0])?t.datasets.forEach(function(t,n){(t.points||t.bars).forEach(function(t,r){t.value=e[n][r]})}):t.segments.forEach(function(t,n){t.value=e[n]}),t.update(),n.$emit("update",t),n.legend&&"false"!==n.legend&&y(r,t)}function b(t){return!t||Array.isArray(t)&&!t.length||"object"==typeof t&&!Object.keys(t).length}function m(r,a){var o=t.extend({},e.defaults.global,n.getOptions(r),a.options);return o.responsive}function w(t,e){t&&(t.destroy(),e.$emit("destroy",t))}return function(e){return{restrict:"CA",scope:{data:"=?",labels:"=?",options:"=?",series:"=?",colours:"=?",getColour:"=?",chartType:"=",legend:"@",click:"=?",hover:"=?",chartData:"=?",chartLabels:"=?",chartOptions:"=?",chartSeries:"=?",chartColours:"=?",chartLegend:"@",chartClick:"=?",chartHover:"=?"},link:function(i,u){function f(t,e){i.$watch(t,function(t){"undefined"!=typeof t&&(i[e]=t)})}function h(n,r){if(!b(n)&&!t.equals(n,r)){var a=e||i.chartType;a&&d(a)}}function d(e){if(m(e,i)&&0===u[0].clientHeight&&0===k.clientHeight)return r(function(){d(e)},50,!1);if(i.data&&i.data.length){i.getColour="function"==typeof i.getColour?i.getColour:s;var a=l(e,i),o=u[0],f=o.getContext("2d"),h=Array.isArray(i.data[0])?p(i.labels,i.data,i.series||[],a):v(i.labels,i.data,a),g=t.extend({},n.getOptions(e),i.options);w(A,i),A=new n.Chart(f)[e](h,g),i.$emit("create",A),o.onclick=i.click?c(i,A,"click",!1):t.noop,o.onmousemove=i.hover?c(i,A,"hover",!0):t.noop,i.legend&&"false"!==i.legend&&y(u,A)}}function g(t){if("undefined"!=typeof console&&"test"!==n.getOptions().env){var e="function"==typeof console.warn?console.warn:console.log;i[t]&&e.call(console,'"%s" is deprecated and will be removed in a future version. Please use "chart-%s" instead.',t,t)}}var A,k=document.createElement("div");k.className="chart-container",u.replaceWith(k),k.appendChild(u[0]),a&&window.G_vmlCanvasManager.initElement(u[0]),["data","labels","options","series","colours","legend","click","hover"].forEach(g),f("chartData","data"),f("chartLabels","labels"),f("chartOptions","options"),f("chartSeries","series"),f("chartColours","colours"),f("chartLegend","legend"),f("chartClick","click"),f("chartHover","hover"),i.$watch("data",function(t,n){if(!t||!t.length||Array.isArray(t[0])&&!t[0].length)return void w(A,i);var r=e||i.chartType;if(r)return A&&o(t,n)?C(A,t,i,u):void d(r)},!0),i.$watch("series",h,!0),i.$watch("labels",h,!0),i.$watch("options",h,!0),i.$watch("colours",h,!0),i.$watch("chartType",function(e,n){b(e)||t.equals(e,n)||d(e)}),i.$on("$destroy",function(){w(A,i)})}}}}e.defaults.global.responsive=!0,e.defaults.global.multiTooltipTemplate="<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",e.defaults.global.colours=["#97BBCD","#DCDCDC","#F7464A","#46BFBD","#FDB45C","#949FB1","#4D5360"];var a="object"==typeof window.G_vmlCanvasManager&&null!==window.G_vmlCanvasManager&&"function"==typeof window.G_vmlCanvasManager.initElement;return a&&(e.defaults.global.animation=!1),t.module("chart.js",[]).provider("ChartJs",n).factory("ChartJsFactory",["ChartJs","$timeout",r]).directive("chartBase",["ChartJsFactory",function(t){return new t}]).directive("chartLine",["ChartJsFactory",function(t){return new t("Line")}]).directive("chartBar",["ChartJsFactory",function(t){return new t("Bar")}]).directive("chartRadar",["ChartJsFactory",function(t){return new t("Radar")}]).directive("chartDoughnut",["ChartJsFactory",function(t){return new t("Doughnut")}]).directive("chartPie",["ChartJsFactory",function(t){return new t("Pie")}]).directive("chartPolarArea",["ChartJsFactory",function(t){return new t("PolarArea")}])}); 2 | //# sourceMappingURL=angular-chart.min.js.map 3 | -------------------------------------------------------------------------------- /src/main/resources/static/js/angular-cookies.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license AngularJS v1.5.5 3 | * (c) 2010-2016 Google, Inc. http://angularjs.org 4 | * License: MIT 5 | */ 6 | (function(window, angular) {'use strict'; 7 | 8 | /** 9 | * @ngdoc module 10 | * @name ngCookies 11 | * @description 12 | * 13 | * # ngCookies 14 | * 15 | * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies. 16 | * 17 | * 18 | *
19 | * 20 | * See {@link ngCookies.$cookies `$cookies`} for usage. 21 | */ 22 | 23 | 24 | angular.module('ngCookies', ['ng']). 25 | /** 26 | * @ngdoc provider 27 | * @name $cookiesProvider 28 | * @description 29 | * Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service. 30 | * */ 31 | provider('$cookies', [function $CookiesProvider() { 32 | /** 33 | * @ngdoc property 34 | * @name $cookiesProvider#defaults 35 | * @description 36 | * 37 | * Object containing default options to pass when setting cookies. 38 | * 39 | * The object may have following properties: 40 | * 41 | * - **path** - `{string}` - The cookie will be available only for this path and its 42 | * sub-paths. By default, this is the URL that appears in your `` tag. 43 | * - **domain** - `{string}` - The cookie will be available only for this domain and 44 | * its sub-domains. For security reasons the user agent will not accept the cookie 45 | * if the current domain is not a sub-domain of this domain or equal to it. 46 | * - **expires** - `{string|Date}` - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" 47 | * or a Date object indicating the exact date/time this cookie will expire. 48 | * - **secure** - `{boolean}` - If `true`, then the cookie will only be available through a 49 | * secured connection. 50 | * 51 | * Note: By default, the address that appears in your `` tag will be used as the path. 52 | * This is important so that cookies will be visible for all routes when html5mode is enabled. 53 | * 54 | **/ 55 | var defaults = this.defaults = {}; 56 | 57 | function calcOptions(options) { 58 | return options ? angular.extend({}, defaults, options) : defaults; 59 | } 60 | 61 | /** 62 | * @ngdoc service 63 | * @name $cookies 64 | * 65 | * @description 66 | * Provides read/write access to browser's cookies. 67 | * 68 | *
69 | * Up until Angular 1.3, `$cookies` exposed properties that represented the 70 | * current browser cookie values. In version 1.4, this behavior has changed, and 71 | * `$cookies` now provides a standard api of getters, setters etc. 72 | *
73 | * 74 | * Requires the {@link ngCookies `ngCookies`} module to be installed. 75 | * 76 | * @example 77 | * 78 | * ```js 79 | * angular.module('cookiesExample', ['ngCookies']) 80 | * .controller('ExampleController', ['$cookies', function($cookies) { 81 | * // Retrieving a cookie 82 | * var favoriteCookie = $cookies.get('myFavorite'); 83 | * // Setting a cookie 84 | * $cookies.put('myFavorite', 'oatmeal'); 85 | * }]); 86 | * ``` 87 | */ 88 | this.$get = ['$$cookieReader', '$$cookieWriter', function($$cookieReader, $$cookieWriter) { 89 | return { 90 | /** 91 | * @ngdoc method 92 | * @name $cookies#get 93 | * 94 | * @description 95 | * Returns the value of given cookie key 96 | * 97 | * @param {string} key Id to use for lookup. 98 | * @returns {string} Raw cookie value. 99 | */ 100 | get: function(key) { 101 | return $$cookieReader()[key]; 102 | }, 103 | 104 | /** 105 | * @ngdoc method 106 | * @name $cookies#getObject 107 | * 108 | * @description 109 | * Returns the deserialized value of given cookie key 110 | * 111 | * @param {string} key Id to use for lookup. 112 | * @returns {Object} Deserialized cookie value. 113 | */ 114 | getObject: function(key) { 115 | var value = this.get(key); 116 | return value ? angular.fromJson(value) : value; 117 | }, 118 | 119 | /** 120 | * @ngdoc method 121 | * @name $cookies#getAll 122 | * 123 | * @description 124 | * Returns a key value object with all the cookies 125 | * 126 | * @returns {Object} All cookies 127 | */ 128 | getAll: function() { 129 | return $$cookieReader(); 130 | }, 131 | 132 | /** 133 | * @ngdoc method 134 | * @name $cookies#put 135 | * 136 | * @description 137 | * Sets a value for given cookie key 138 | * 139 | * @param {string} key Id for the `value`. 140 | * @param {string} value Raw value to be stored. 141 | * @param {Object=} options Options object. 142 | * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} 143 | */ 144 | put: function(key, value, options) { 145 | $$cookieWriter(key, value, calcOptions(options)); 146 | }, 147 | 148 | /** 149 | * @ngdoc method 150 | * @name $cookies#putObject 151 | * 152 | * @description 153 | * Serializes and sets a value for given cookie key 154 | * 155 | * @param {string} key Id for the `value`. 156 | * @param {Object} value Value to be stored. 157 | * @param {Object=} options Options object. 158 | * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} 159 | */ 160 | putObject: function(key, value, options) { 161 | this.put(key, angular.toJson(value), options); 162 | }, 163 | 164 | /** 165 | * @ngdoc method 166 | * @name $cookies#remove 167 | * 168 | * @description 169 | * Remove given cookie 170 | * 171 | * @param {string} key Id of the key-value pair to delete. 172 | * @param {Object=} options Options object. 173 | * See {@link ngCookies.$cookiesProvider#defaults $cookiesProvider.defaults} 174 | */ 175 | remove: function(key, options) { 176 | $$cookieWriter(key, undefined, calcOptions(options)); 177 | } 178 | }; 179 | }]; 180 | }]); 181 | 182 | angular.module('ngCookies'). 183 | /** 184 | * @ngdoc service 185 | * @name $cookieStore 186 | * @deprecated 187 | * @requires $cookies 188 | * 189 | * @description 190 | * Provides a key-value (string-object) storage, that is backed by session cookies. 191 | * Objects put or retrieved from this storage are automatically serialized or 192 | * deserialized by angular's toJson/fromJson. 193 | * 194 | * Requires the {@link ngCookies `ngCookies`} module to be installed. 195 | * 196 | *
197 | * **Note:** The $cookieStore service is **deprecated**. 198 | * Please use the {@link ngCookies.$cookies `$cookies`} service instead. 199 | *
200 | * 201 | * @example 202 | * 203 | * ```js 204 | * angular.module('cookieStoreExample', ['ngCookies']) 205 | * .controller('ExampleController', ['$cookieStore', function($cookieStore) { 206 | * // Put cookie 207 | * $cookieStore.put('myFavorite','oatmeal'); 208 | * // Get cookie 209 | * var favoriteCookie = $cookieStore.get('myFavorite'); 210 | * // Removing a cookie 211 | * $cookieStore.remove('myFavorite'); 212 | * }]); 213 | * ``` 214 | */ 215 | factory('$cookieStore', ['$cookies', function($cookies) { 216 | 217 | return { 218 | /** 219 | * @ngdoc method 220 | * @name $cookieStore#get 221 | * 222 | * @description 223 | * Returns the value of given cookie key 224 | * 225 | * @param {string} key Id to use for lookup. 226 | * @returns {Object} Deserialized cookie value, undefined if the cookie does not exist. 227 | */ 228 | get: function(key) { 229 | return $cookies.getObject(key); 230 | }, 231 | 232 | /** 233 | * @ngdoc method 234 | * @name $cookieStore#put 235 | * 236 | * @description 237 | * Sets a value for given cookie key 238 | * 239 | * @param {string} key Id for the `value`. 240 | * @param {Object} value Value to be stored. 241 | */ 242 | put: function(key, value) { 243 | $cookies.putObject(key, value); 244 | }, 245 | 246 | /** 247 | * @ngdoc method 248 | * @name $cookieStore#remove 249 | * 250 | * @description 251 | * Remove given cookie 252 | * 253 | * @param {string} key Id of the key-value pair to delete. 254 | */ 255 | remove: function(key) { 256 | $cookies.remove(key); 257 | } 258 | }; 259 | 260 | }]); 261 | 262 | /** 263 | * @name $$cookieWriter 264 | * @requires $document 265 | * 266 | * @description 267 | * This is a private service for writing cookies 268 | * 269 | * @param {string} name Cookie name 270 | * @param {string=} value Cookie value (if undefined, cookie will be deleted) 271 | * @param {Object=} options Object with options that need to be stored for the cookie. 272 | */ 273 | function $$CookieWriter($document, $log, $browser) { 274 | var cookiePath = $browser.baseHref(); 275 | var rawDocument = $document[0]; 276 | 277 | function buildCookieString(name, value, options) { 278 | var path, expires; 279 | options = options || {}; 280 | expires = options.expires; 281 | path = angular.isDefined(options.path) ? options.path : cookiePath; 282 | if (angular.isUndefined(value)) { 283 | expires = 'Thu, 01 Jan 1970 00:00:00 GMT'; 284 | value = ''; 285 | } 286 | if (angular.isString(expires)) { 287 | expires = new Date(expires); 288 | } 289 | 290 | var str = encodeURIComponent(name) + '=' + encodeURIComponent(value); 291 | str += path ? ';path=' + path : ''; 292 | str += options.domain ? ';domain=' + options.domain : ''; 293 | str += expires ? ';expires=' + expires.toUTCString() : ''; 294 | str += options.secure ? ';secure' : ''; 295 | 296 | // per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum: 297 | // - 300 cookies 298 | // - 20 cookies per unique domain 299 | // - 4096 bytes per cookie 300 | var cookieLength = str.length + 1; 301 | if (cookieLength > 4096) { 302 | $log.warn("Cookie '" + name + 303 | "' possibly not set or overflowed because it was too large (" + 304 | cookieLength + " > 4096 bytes)!"); 305 | } 306 | 307 | return str; 308 | } 309 | 310 | return function(name, value, options) { 311 | rawDocument.cookie = buildCookieString(name, value, options); 312 | }; 313 | } 314 | 315 | $$CookieWriter.$inject = ['$document', '$log', '$browser']; 316 | 317 | angular.module('ngCookies').provider('$$cookieWriter', function $$CookieWriterProvider() { 318 | this.$get = $$CookieWriter; 319 | }); 320 | 321 | 322 | })(window, window.angular); 323 | -------------------------------------------------------------------------------- /src/main/resources/static/js/angular-materialize.min.js: -------------------------------------------------------------------------------- 1 | (function(e){var i;e.module("ui.materialize",["ui.materialize.ngModel","ui.materialize.collapsible","ui.materialize.toast","ui.materialize.sidenav","ui.materialize.material_select","ui.materialize.dropdown","ui.materialize.inputfield","ui.materialize.input_date","ui.materialize.tabs","ui.materialize.pagination","ui.materialize.pushpin","ui.materialize.scrollspy","ui.materialize.parallax","ui.materialize.modal","ui.materialize.tooltipped","ui.materialize.slider","ui.materialize.materialboxed","ui.materialize.scrollFire","ui.materialize.nouislider","ui.materialize.input_clock"]);e.module("ui.materialize.scrollFire",[]).directive("scrollFire",["$compile","$timeout",function(i,n){return{restrict:"A",scope:{offset:"@",scrollFire:"&"},link:function(i,n,a){var o=i.offset;if(!e.isDefined(i.offset)){o=0}o=Number(o)||0;var r=false;var l=t(function(){console.log("Handler");if(r){return}var e=window.pageYOffset+window.innerHeight;var t=n[0].getBoundingClientRect().top+window.pageYOffset;console.log(typeof o);console.log(e-(t+o)+" left");if(e>t+o){r=true;i.scrollFire({});s()}},100);function s(){$(window).off("scroll resize blur focus",l)}$(window).on("scroll resize blur focus",l);l();i.$on("$destroy",s)}}}]);function t(e,i){var t,n,a,o;var r=0;var l=function(){r=+new Date;t=null;o=e.apply(n,a);if(!t)n=a=null};var s=function(){var s=+new Date;var u=i-(s-r);n=this;a=arguments;if(u<=0||u>i){if(t){clearTimeout(t);t=null}r=s;o=e.apply(n,a);if(!t)n=a=null}else if(!t){t=setTimeout(l,u)}return o};s.cancel=function(){clearTimeout(t);r=0;t=n=a=null};return s}e.module("ui.materialize.ngModel",[]).directive("ngModel",["$timeout",function(e){return{restrict:"A",priority:-1,link:function(t,n,a){t.$watch(a.ngModel,function(t,a){e(function(){if(t instanceof Array&&a instanceof Array){if(t.length==a.length){return}}if(t){n.trigger("change")}else if(n.attr("placeholder")===i){if(!n.is(":focus"))n.trigger("blur")}})})}}}]);e.module("ui.materialize.slider",[]).directive("slider",["$timeout",function(i){return{restrict:"A",scope:{height:"=",transition:"=",interval:"=",indicators:"="},link:function(t,n,a){n.addClass("slider");i(function(){n.slider({height:e.isDefined(t.height)?t.height:400,transition:e.isDefined(t.transition)?t.transition:500,interval:e.isDefined(t.interval)?t.interval:6e3,indicators:e.isDefined(t.indicators)?t.indicators:true})})}}}]);e.module("ui.materialize.collapsible",[]).directive("collapsible",["$timeout",function(e){return{link:function(i,t,n){e(function(){t.collapsible()});if("watch"in n){i.$watch(function(){return t[0].innerHTML},function(i,n){if(i!==n){e(function(){t.collapsible()})}})}}}}]);e.module("ui.materialize.parallax",[]).directive("parallax",["$timeout",function(e){return{link:function(i,t,n){e(function(){t.parallax()})}}}]);e.module("ui.materialize.toast",[]).constant("toastConfig",{duration:3e3}).directive("toast",["toastConfig",function(i){return{scope:{message:"@",duration:"@",callback:"&"},link:function(t,n,a){n.bind(a.toast,function(){var n=e.isDefined(t.message)?t.message:"";var o=e.isDefined(a.toastclass)?a.toastclass:"";Materialize.toast(n,t.duration?t.duration:i.duration,o,t.callback)})}}}]);e.module("ui.materialize.pushpin",[]).directive("pushpin",[function(){return{restrict:"AE",require:["?pushpinTop","?pushpinOffset","?pushpinBottom"],link:function(e,i,t){var n=t.pushpinTop||0;var a=t.pushpinOffset||0;var o=t.pushpinBottom||Infinity;setTimeout(function(){i.pushpin({top:n,offset:a,bottom:o})},0)}}}]);e.module("ui.materialize.scrollspy",[]).directive("scrollspy",["$timeout",function(e){return{restrict:"A",link:function(i,t,n){t.addClass("scrollspy");e(function(){t.scrollSpy()})}}}]);e.module("ui.materialize.tabs",[]).directive("tabs",["$timeout",function(e){return{link:function(i,t,n){t.addClass("tabs");e(function(){t.tabs()})}}}]);e.module("ui.materialize.sidenav",[]).directive("sidenav",[function(){return{scope:{menuwidth:"@",closeonclick:"@"},link:function(t,n,a){n.sideNav({menuWidth:e.isDefined(t.menuwidth)?parseInt(t.menuwidth,10):i,edge:a.sidenav?a.sidenav:"left",closeOnClick:e.isDefined(t.closeonclick)?t.closeonclick=="true":i})}}}]);e.module("ui.materialize.material_select",[]).directive("materialSelect",["$compile","$timeout",function(e,t){return{link:function(e,n,a){if(n.is("select")){function o(t,o){if(a.multiple){if(o!==i&&t!==i){if(o.length===t.length){return}}var r=n.siblings("ul.active");if(t!==i&&r.length){var l=r.children("li.active").length;if(l==t.length){return}}}else{if(t==n.val()){return}}n.siblings(".caret").remove();e.$evalAsync(function(){n.material_select()})}t(o);if(a.ngModel){e.$watch(a.ngModel,o)}if("watch"in a){e.$watch(function(){return n[0].innerHTML},function(e,i){if(e!==i){t(o)}})}}}}}]);e.module("ui.materialize.dropdown",[]).directive("dropdown",["$timeout",function(t){return{scope:{inDuration:"@",outDuration:"@",constrainWidth:"@",hover:"@",alignment:"@",gutter:"@",belowOrigin:"@"},link:function(n,a,o){t(function(){a.dropdown({inDuration:e.isDefined(n.inDuration)?n.inDuration:i,outDuration:e.isDefined(n.outDuration)?n.outDuration:i,constrain_width:e.isDefined(n.constrainWidth)?n.constrainWidth:i,hover:e.isDefined(n.hover)?n.hover:i,alignment:e.isDefined(n.alignment)?n.alignment:i,gutter:e.isDefined(n.gutter)?n.gutter:i,belowOrigin:e.isDefined(n.belowOrigin)?n.belowOrigin:i})})}}}]);e.module("ui.materialize.inputfield",[]).directive("inputField",["$timeout",function(i){return{transclude:true,scope:{},link:function(t,n){i(function(){Materialize.updateTextFields();n.find("> > .materialize-textarea").each(function(){var e=$(this);e.addClass("materialize-textarea");e.trigger("autoresize");var n=e.attr("ng-model");if(n){t.$parent.$watch(n,function(t,n){if(t!==n){i(function(){e.trigger("autoresize")})}})}});n.find("> > .materialize-textarea, > > input").each(function(i,t){t=e.element(t);if(!t.siblings('span[class="character-counter"]').length){t.characterCounter()}})})},template:'
'}}]);e.module("ui.materialize.input_date",[]).directive("inputDate",["$compile","$timeout",function(t,n){var a=$("");$("html > head").append(a);var o=function(){var e=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,t=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,n=/[^-+\dA-Z]/g,a=function(e,i){e=String(e);i=i||2;while(e.length99?Math.round(y/10):y),t:g<12?"a":"p",tt:g<12?"am":"pm",T:g<12?"A":"P",TT:g<12?"AM":"PM",Z:s?"UTC":(String(r).match(t)||[""]).pop().replace(n,""),o:(D>0?"-":"+")+a(Math.floor(Math.abs(D)/60)*100+Math.abs(D)%60,4),S:["th","st","nd","rd"][d%10>3?0:(d%100-d%10!=10)*d%10]};return l.replace(e,function(e){return e in b?b[e]:e.slice(1,e.length-1)})}}();o.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};o.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};Date.prototype.format=function(e,i){return o(this,e,i)};var r=function(e){if(Object.prototype.toString.call(e)==="[object Date]"){return!isNaN(e.getTime())}return false};return{require:"ngModel",scope:{container:"@",format:"@",formatSubmit:"@",monthsFull:"@",monthsShort:"@",weekdaysFull:"@",weekdaysShort:"@",weekdaysLetter:"@",firstDay:"=",disable:"=",today:"=",clear:"=",close:"=",selectYears:"=",onStart:"&",onRender:"&",onOpen:"&",onClose:"&",onSet:"&",onStop:"&",ngReadonly:"=?",max:"@",min:"@"},link:function(a,o,l,s){s.$formatters.unshift(function(i){if(i){var t=new Date(i);return e.isDefined(a.format)?t.format(a.format):t.format("d mmmm, yyyy")}return null});var u=e.isDefined(a.monthsFull)?a.$eval(a.monthsFull):i,c=e.isDefined(a.monthsShort)?a.$eval(a.monthsShort):i,d=e.isDefined(a.weekdaysFull)?a.$eval(a.weekdaysFull):i,f=e.isDefined(a.weekdaysShort)?a.$eval(a.weekdaysShort):i,m=e.isDefined(a.weekdaysLetter)?a.$eval(a.weekdaysLetter):i;t(o.contents())(a);if(!a.ngReadonly){n(function(){var t=o.pickadate({container:e.isDefined(a.container)?a.container:"body",format:e.isDefined(a.format)?a.format:i,formatSubmit:e.isDefined(a.formatSubmit)?a.formatSubmit:i,monthsFull:e.isDefined(u)?u:i,monthsShort:e.isDefined(c)?c:i,weekdaysFull:e.isDefined(d)?d:i,weekdaysShort:e.isDefined(f)?f:i,weekdaysLetter:e.isDefined(m)?m:i,firstDay:e.isDefined(a.firstDay)?a.firstDay:0,disable:e.isDefined(a.disable)?a.disable:i,today:e.isDefined(a.today)?a.today:i,clear:e.isDefined(a.clear)?a.clear:i,close:e.isDefined(a.close)?a.close:i,selectYears:e.isDefined(a.selectYears)?a.selectYears:i,onStart:e.isDefined(a.onStart)?function(){a.onStart()}:i,onRender:e.isDefined(a.onRender)?function(){a.onRender()}:i,onOpen:e.isDefined(a.onOpen)?function(){a.onOpen()}:i,onClose:e.isDefined(a.onClose)?function(){a.onClose()}:i,onSet:e.isDefined(a.onSet)?function(){a.onSet()}:i,onStop:e.isDefined(a.onStop)?function(){a.onStop()}:i});var n=t.pickadate("picker");a.$watch("max",function(e){if(n){var i=new Date(e);n.set({max:r(i)?i:false})}});a.$watch("min",function(e){if(n){var i=new Date(e);n.set({min:r(i)?i:false})}})})}}}}]);e.module("ui.materialize.input_clock",[]).directive("inputClock",[function(){return{restrict:"A",scope:{"default":"@",fromnow:"=?",donetext:"@",autoclose:"=?",ampmclickable:"=?",darktheme:"=?",twelvehour:"=?",vibrate:"=?"},link:function(i,t){$(t).addClass("timepicker");if(!i.ngReadonly){t.clockpicker({"default":e.isDefined(i.default)?i.default:"",fromnow:e.isDefined(i.fromnow)?i.fromnow:0,donetext:e.isDefined(i.donetext)?i.donetext:"Done",autoclose:e.isDefined(i.autoclose)?i.autoclose:false,ampmclickable:e.isDefined(i.ampmclickable)?i.ampmclickable:false,darktheme:e.isDefined(i.darktheme)?i.darktheme:false,twelvehour:e.isDefined(i.twelvehour)?i.twelvehour:true,vibrate:e.isDefined(i.vibrate)?i.vibrate:true})}}}}]);e.module("ui.materialize.pagination",[]).directive("pagination",["$sce",function(e){function i(e,i){e.List=[];e.Hide=false;e.page=parseInt(e.page)||1;e.total=parseInt(e.total)||0;e.dots=e.dots||"...";e.ulClass=e.ulClass||i.ulClass||"pagination";e.adjacent=parseInt(e.adjacent)||2;e.activeClass="active";e.disabledClass="disabled";e.scrollTop=e.$eval(i.scrollTop);e.hideIfEmpty=e.$eval(i.hideIfEmpty);e.showPrevNext=e.$eval(i.showPrevNext);e.useSimplePrevNext=e.$eval(i.useSimplePrevNext)}function t(e,i){if(e.page>i){e.page=i}if(e.page<=0){e.page=1}if(e.adjacent<=0){e.adjacent=2}if(i<=1){e.Hide=e.hideIfEmpty}}function n(e,i){i=i.valueOf();if(e.page==i){return}e.page=i;e.paginationAction({page:i});if(e.scrollTop){scrollTo(0,0)}}function a(i,t,a){var o=0;for(o=i;o<=t;o++){var r={value:e.trustAsHtml(o.toString()),liClass:a.page==o?a.activeClass:"waves-effect",action:function(){n(a,this.value)}};a.List.push(r)}}function o(i){i.List.push({value:e.trustAsHtml(i.dots)})}function r(e,i){a(1,2,e);if(i!=3){o(e)}}function l(i,t,a){if(!i.showPrevNext||t<1){return}var o,r,l;if(a==="prev"){o=i.page-1<=0;var s=i.page-1<=0?1:i.page-1;if(i.useSimplePrevNext){r={value:"<<",title:"First Page",page:1};l={value:"<",title:"Previous Page",page:s}}else{r={value:'first_page',title:"First Page",page:1};l={value:'chevron_left',title:"Previous Page",page:s}}}else{o=i.page+1>t;var u=i.page+1>=t?t:i.page+1;if(i.useSimplePrevNext){r={value:">",title:"Next Page",page:u};l={value:">>",title:"Last Page",page:t}}else{r={value:'chevron_right',title:"Next Page",page:u};l={value:'last_page',title:"Last Page",page:t}}}var c=function(t,a){i.List.push({value:e.trustAsHtml(t.value),title:t.title,liClass:a?i.disabledClass:"",action:function(){if(!a){n(i,t.page)}}})};c(r,o);c(l,o)}function s(e,i,t){if(t!=e-2){o(i)}a(e-1,e,i)}function u(e,n){if(!e.pageSize||e.pageSize<0){return}i(e,n);var o,u=e.adjacent*2,c=Math.ceil(e.total/e.pageSize);t(e,c);l(e,c,"prev");if(c<5+u){o=1;a(o,c,e)}else{var d;if(e.page<=1+u){o=1;d=2+u+(e.adjacent-1);a(o,d,e);s(c,e,d)}else if(c-u>e.page&&e.page>u){o=e.page-e.adjacent;d=e.page+e.adjacent;r(e,o);a(o,d,e);s(c,e,d)}else{o=c-(1+u+(e.adjacent-1));d=c;r(e,o);a(o,d,e)}}l(e,c,"next")}return{restrict:"EA",scope:{page:"=",pageSize:"=",total:"=",dots:"@",hideIfEmpty:"@",adjacent:"@",scrollTop:"@",showPrevNext:"@",useSimplePrevNext:"@",paginationAction:"&",ulClass:"=?"},template:'",link:function(e,i,t){e.$watchCollection("[page, total, pageSize]",function(){u(e,t)})}}}]);e.module("ui.materialize.modal",[]).directive("modal",["$compile","$timeout",function(t,n){return{scope:{dismissible:"=",opacity:"@",inDuration:"@",outDuration:"@",ready:"&?",complete:"&?",open:"=?",enableTabs:"@?"},link:function(a,o,r){n(function(){var n=$(r.href?r.href:"#"+r.target);t(o.contents())(a);var l=function(){e.isFunction(a.complete)&&a.$eval(a.complete());a.open=false;a.$apply()};var s=function(){e.isFunction(a.ready)&&a.$eval(a.ready());if(a.enableTabs){n.find("ul.tabs").tabs()}};var u={dismissible:e.isDefined(a.dismissible)?a.dismissible:i,opacity:e.isDefined(a.opacity)?a.opacity:i,in_duration:e.isDefined(a.inDuration)?a.inDuration:i,out_duration:e.isDefined(a.outDuration)?a.outDuration:i,ready:s,complete:l};o.leanModal(u);if(e.isDefined(r.open)&&n.length>0){a.$watch("open",function(i,t){if(!e.isDefined(i)){return}i===true?n.openModal(u):n.closeModal()})}})}}}]);e.module("ui.materialize.tooltipped",[]).directive("tooltipped",["$compile","$timeout",function(e,i){return{restrict:"EA",scope:true,link:function(t,n,a){n.addClass("tooltipped");e(n.contents())(t);i(function(){n.tooltip()});t.$on("$destroy",function(){n.tooltip("remove")})}}}]);e.module("ui.materialize.materialboxed",[]).directive("materialboxed",["$timeout",function(e){return{restrict:"A",link:function(i,t,n){e(function(){t.materialbox()})}}}]);e.module("ui.materialize.nouislider",[]).directive("nouislider",["$timeout",function(t){return{restrict:"A",scope:{ngModel:"=",min:"@",max:"@",step:"@?",connect:"@?",tooltips:"@?"},link:function(n,a,o){t(function(){noUiSlider.create(a[0],{start:n.ngModel||0,step:parseFloat(n.step||1),tooltips:e.isDefined(n.connect)?n.tooltips:i,connect:e.isDefined(n.connect)?n.connect:"lower",range:{min:parseFloat(n.min||0),max:parseFloat(n.max||100)},format:{to:function(e){return Math.round(e*100)/100},from:function(e){return Number(e)}}});a[0].noUiSlider.on("update",function(e,i){n.ngModel=parseInt(e[0],10);n.$apply()})})}}}])})(angular); -------------------------------------------------------------------------------- /src/main/resources/static/js/angular-pageslide-directive.min.js: -------------------------------------------------------------------------------- 1 | /*! angular-pageslide-directive 2016-05-19 */ 2 | angular.module("pageslide-directive",[]).directive("pageslide",["$document","$timeout",function(a,b){return{restrict:"EAC",transclude:!1,scope:{psOpen:"=?",psAutoClose:"=?",psSide:"@",psSpeed:"@",psClass:"@",psSize:"@",psZindex:"@",psSqueeze:"@",psCloak:"@",psPush:"@",psContainer:"@",psKeyListener:"@",psBodyClass:"@",psClickOutside:"@"},link:function(c,d,e){function f(a){o&&!m.contains(a.target)&&(o=!1,c.psOpen=!1,c.$apply()),c.psOpen&&(o=!0)}function g(a){if(k.bodyClass){var b=k.className+"-body",c=new RegExp(" "+b+"-closed| "+b+"-open");n.className=n.className.replace(c,""),n.className+=" "+b+"-"+a}}function h(b,d){if(b&&0!==b.style.width)switch(l.css("display","none"),d.side){case"right":b.style.width="0px",d.squeeze&&(n.style.right="0px"),d.push&&(n.style.right="0px",n.style.left="0px");break;case"left":b.style.width="0px",d.squeeze&&(n.style.left="0px"),d.push&&(n.style.left="0px",n.style.right="0px");break;case"top":b.style.height="0px",d.squeeze&&(n.style.top="0px"),d.push&&(n.style.top="0px",n.style.bottom="0px");break;case"bottom":b.style.height="0px",d.squeeze&&(n.style.bottom="0px"),d.push&&(n.style.bottom="0px",n.style.top="0px")}c.psOpen=!1,d.keyListener&&a.off("keydown",j),d.clickOutside&&a.off("click",f),o=!1,g("closed")}function i(d,e){if(0!==d.style.width){switch(e.side){case"right":d.style.width=e.size,e.squeeze&&(n.style.right=e.size),e.push&&(n.style.right=e.size,n.style.left="-"+e.size);break;case"left":d.style.width=e.size,e.squeeze&&(n.style.left=e.size),e.push&&(n.style.left=e.size,n.style.right="-"+e.size);break;case"top":d.style.height=e.size,e.squeeze&&(n.style.top=e.size),e.push&&(n.style.top=e.size,n.style.bottom="-"+e.size);break;case"bottom":d.style.height=e.size,e.squeeze&&(n.style.bottom=e.size),e.push&&(n.style.bottom=e.size,n.style.top="-"+e.size)}b(function(){l.css("display","block")},1e3*e.speed),c.psOpen=!0,e.keyListener&&a.on("keydown",j),e.clickOutside&&a.on("click",f),g("open")}}function j(a){var b=27,c=a.keyCode||a.which;c===b&&h(m,k)}var k={};k.side=c.psSide||"right",k.speed=c.psSpeed||"0.5",k.size=c.psSize||"300px",k.zindex=c.psZindex||1e3,k.className=c.psClass||"ng-pageslide",k.squeeze="true"===c.psSqueeze,k.push="true"===c.psPush,k.container=c.psContainer||!1,k.keyListener="true"===c.psKeyListener,k.bodyClass=c.psBodyClass||!1,k.clickOutside="false"!==c.psClickOutside,d.addClass(k.className);var l,m,n;n=k.container?document.getElementById(k.container):document.body;var o=!1;if(g("closed"),m=d[0],"div"!==m.tagName.toLowerCase()&&"pageslide"!==m.tagName.toLowerCase())throw new Error("Pageslide can only be applied to
or elements");if(0===m.children.length)throw new Error("You have to content inside the ");switch(l=angular.element(m.children),n.appendChild(m),m.style.zIndex=k.zindex,m.style.position=k.container!==!1?"absolute":"fixed",m.style.width=0,m.style.height=0,m.style.transitionDuration=k.speed+"s",m.style.webkitTransitionDuration=k.speed+"s",m.style.transitionProperty="width, height",k.squeeze&&(n.style.position="absolute",n.style.transitionDuration=k.speed+"s",n.style.webkitTransitionDuration=k.speed+"s",n.style.transitionProperty="top, bottom, left, right"),k.side){case"right":m.style.height=e.psCustomHeight||"100%",m.style.top=e.psCustomTop||"0px",m.style.bottom=e.psCustomBottom||"0px",m.style.right=e.psCustomRight||"0px";break;case"left":m.style.height=e.psCustomHeight||"100%",m.style.top=e.psCustomTop||"0px",m.style.bottom=e.psCustomBottom||"0px",m.style.left=e.psCustomLeft||"0px";break;case"top":m.style.width=e.psCustomWidth||"100%",m.style.left=e.psCustomLeft||"0px",m.style.top=e.psCustomTop||"0px",m.style.right=e.psCustomRight||"0px";break;case"bottom":m.style.width=e.psCustomWidth||"100%",m.style.bottom=e.psCustomBottom||"0px",m.style.left=e.psCustomLeft||"0px",m.style.right=e.psCustomRight||"0px"}c.$watch("psOpen",function(a){a?i(m,k):h(m,k)}),c.$watch("psSize",function(a,b){b!==a&&(k.size=a,i(m,k))}),c.$on("$destroy",function(){m.parentNode===n&&(k.clickOutside&&a.off("click",f),n.removeChild(m))}),c.psAutoClose&&(c.$on("$locationChangeStart",function(){h(m,k)}),c.$on("$stateChangeStart",function(){h(m,k)}))}}}]); -------------------------------------------------------------------------------- /src/main/resources/static/js/angular-route.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license AngularJS v1.5.5 3 | * (c) 2010-2016 Google, Inc. http://angularjs.org 4 | * License: MIT 5 | */ 6 | (function(window, angular) {'use strict'; 7 | 8 | /** 9 | * @ngdoc module 10 | * @name ngRoute 11 | * @description 12 | * 13 | * # ngRoute 14 | * 15 | * The `ngRoute` module provides routing and deeplinking services and directives for angular apps. 16 | * 17 | * ## Example 18 | * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. 19 | * 20 | * 21 | *
22 | */ 23 | /* global -ngRouteModule */ 24 | var ngRouteModule = angular.module('ngRoute', ['ng']). 25 | provider('$route', $RouteProvider), 26 | $routeMinErr = angular.$$minErr('ngRoute'); 27 | 28 | /** 29 | * @ngdoc provider 30 | * @name $routeProvider 31 | * 32 | * @description 33 | * 34 | * Used for configuring routes. 35 | * 36 | * ## Example 37 | * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. 38 | * 39 | * ## Dependencies 40 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 41 | */ 42 | function $RouteProvider() { 43 | function inherit(parent, extra) { 44 | return angular.extend(Object.create(parent), extra); 45 | } 46 | 47 | var routes = {}; 48 | 49 | /** 50 | * @ngdoc method 51 | * @name $routeProvider#when 52 | * 53 | * @param {string} path Route path (matched against `$location.path`). If `$location.path` 54 | * contains redundant trailing slash or is missing one, the route will still match and the 55 | * `$location.path` will be updated to add or drop the trailing slash to exactly match the 56 | * route definition. 57 | * 58 | * * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up 59 | * to the next slash are matched and stored in `$routeParams` under the given `name` 60 | * when the route matches. 61 | * * `path` can contain named groups starting with a colon and ending with a star: 62 | * e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name` 63 | * when the route matches. 64 | * * `path` can contain optional named groups with a question mark: e.g.`:name?`. 65 | * 66 | * For example, routes like `/color/:color/largecode/:largecode*\/edit` will match 67 | * `/color/brown/largecode/code/with/slashes/edit` and extract: 68 | * 69 | * * `color: brown` 70 | * * `largecode: code/with/slashes`. 71 | * 72 | * 73 | * @param {Object} route Mapping information to be assigned to `$route.current` on route 74 | * match. 75 | * 76 | * Object properties: 77 | * 78 | * - `controller` – `{(string|function()=}` – Controller fn that should be associated with 79 | * newly created scope or the name of a {@link angular.Module#controller registered 80 | * controller} if passed as a string. 81 | * - `controllerAs` – `{string=}` – An identifier name for a reference to the controller. 82 | * If present, the controller will be published to scope under the `controllerAs` name. 83 | * - `template` – `{string=|function()=}` – html template as a string or a function that 84 | * returns an html template as a string which should be used by {@link 85 | * ngRoute.directive:ngView ngView} or {@link ng.directive:ngInclude ngInclude} directives. 86 | * This property takes precedence over `templateUrl`. 87 | * 88 | * If `template` is a function, it will be called with the following parameters: 89 | * 90 | * - `{Array.}` - route parameters extracted from the current 91 | * `$location.path()` by applying the current route 92 | * 93 | * - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html 94 | * template that should be used by {@link ngRoute.directive:ngView ngView}. 95 | * 96 | * If `templateUrl` is a function, it will be called with the following parameters: 97 | * 98 | * - `{Array.}` - route parameters extracted from the current 99 | * `$location.path()` by applying the current route 100 | * 101 | * - `resolve` - `{Object.=}` - An optional map of dependencies which should 102 | * be injected into the controller. If any of these dependencies are promises, the router 103 | * will wait for them all to be resolved or one to be rejected before the controller is 104 | * instantiated. 105 | * If all the promises are resolved successfully, the values of the resolved promises are 106 | * injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is 107 | * fired. If any of the promises are rejected the 108 | * {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired. 109 | * For easier access to the resolved dependencies from the template, the `resolve` map will 110 | * be available on the scope of the route, under `$resolve` (by default) or a custom name 111 | * specified by the `resolveAs` property (see below). This can be particularly useful, when 112 | * working with {@link angular.Module#component components} as route templates.
113 | *
114 | * **Note:** If your scope already contains a property with this name, it will be hidden 115 | * or overwritten. Make sure, you specify an appropriate name for this property, that 116 | * does not collide with other properties on the scope. 117 | *
118 | * The map object is: 119 | * 120 | * - `key` – `{string}`: a name of a dependency to be injected into the controller. 121 | * - `factory` - `{string|function}`: If `string` then it is an alias for a service. 122 | * Otherwise if function, then it is {@link auto.$injector#invoke injected} 123 | * and the return value is treated as the dependency. If the result is a promise, it is 124 | * resolved before its value is injected into the controller. Be aware that 125 | * `ngRoute.$routeParams` will still refer to the previous route within these resolve 126 | * functions. Use `$route.current.params` to access the new route parameters, instead. 127 | * 128 | * - `resolveAs` - `{string=}` - The name under which the `resolve` map will be available on 129 | * the scope of the route. If omitted, defaults to `$resolve`. 130 | * 131 | * - `redirectTo` – `{(string|function())=}` – value to update 132 | * {@link ng.$location $location} path with and trigger route redirection. 133 | * 134 | * If `redirectTo` is a function, it will be called with the following parameters: 135 | * 136 | * - `{Object.}` - route parameters extracted from the current 137 | * `$location.path()` by applying the current route templateUrl. 138 | * - `{string}` - current `$location.path()` 139 | * - `{Object}` - current `$location.search()` 140 | * 141 | * The custom `redirectTo` function is expected to return a string which will be used 142 | * to update `$location.path()` and `$location.search()`. 143 | * 144 | * - `[reloadOnSearch=true]` - `{boolean=}` - reload route when only `$location.search()` 145 | * or `$location.hash()` changes. 146 | * 147 | * If the option is set to `false` and url in the browser changes, then 148 | * `$routeUpdate` event is broadcasted on the root scope. 149 | * 150 | * - `[caseInsensitiveMatch=false]` - `{boolean=}` - match routes without being case sensitive 151 | * 152 | * If the option is set to `true`, then the particular route can be matched without being 153 | * case sensitive 154 | * 155 | * @returns {Object} self 156 | * 157 | * @description 158 | * Adds a new route definition to the `$route` service. 159 | */ 160 | this.when = function(path, route) { 161 | //copy original route object to preserve params inherited from proto chain 162 | var routeCopy = angular.copy(route); 163 | if (angular.isUndefined(routeCopy.reloadOnSearch)) { 164 | routeCopy.reloadOnSearch = true; 165 | } 166 | if (angular.isUndefined(routeCopy.caseInsensitiveMatch)) { 167 | routeCopy.caseInsensitiveMatch = this.caseInsensitiveMatch; 168 | } 169 | routes[path] = angular.extend( 170 | routeCopy, 171 | path && pathRegExp(path, routeCopy) 172 | ); 173 | 174 | // create redirection for trailing slashes 175 | if (path) { 176 | var redirectPath = (path[path.length - 1] == '/') 177 | ? path.substr(0, path.length - 1) 178 | : path + '/'; 179 | 180 | routes[redirectPath] = angular.extend( 181 | {redirectTo: path}, 182 | pathRegExp(redirectPath, routeCopy) 183 | ); 184 | } 185 | 186 | return this; 187 | }; 188 | 189 | /** 190 | * @ngdoc property 191 | * @name $routeProvider#caseInsensitiveMatch 192 | * @description 193 | * 194 | * A boolean property indicating if routes defined 195 | * using this provider should be matched using a case insensitive 196 | * algorithm. Defaults to `false`. 197 | */ 198 | this.caseInsensitiveMatch = false; 199 | 200 | /** 201 | * @param path {string} path 202 | * @param opts {Object} options 203 | * @return {?Object} 204 | * 205 | * @description 206 | * Normalizes the given path, returning a regular expression 207 | * and the original path. 208 | * 209 | * Inspired by pathRexp in visionmedia/express/lib/utils.js. 210 | */ 211 | function pathRegExp(path, opts) { 212 | var insensitive = opts.caseInsensitiveMatch, 213 | ret = { 214 | originalPath: path, 215 | regexp: path 216 | }, 217 | keys = ret.keys = []; 218 | 219 | path = path 220 | .replace(/([().])/g, '\\$1') 221 | .replace(/(\/)?:(\w+)(\*\?|[\?\*])?/g, function(_, slash, key, option) { 222 | var optional = (option === '?' || option === '*?') ? '?' : null; 223 | var star = (option === '*' || option === '*?') ? '*' : null; 224 | keys.push({ name: key, optional: !!optional }); 225 | slash = slash || ''; 226 | return '' 227 | + (optional ? '' : slash) 228 | + '(?:' 229 | + (optional ? slash : '') 230 | + (star && '(.+?)' || '([^/]+)') 231 | + (optional || '') 232 | + ')' 233 | + (optional || ''); 234 | }) 235 | .replace(/([\/$\*])/g, '\\$1'); 236 | 237 | ret.regexp = new RegExp('^' + path + '$', insensitive ? 'i' : ''); 238 | return ret; 239 | } 240 | 241 | /** 242 | * @ngdoc method 243 | * @name $routeProvider#otherwise 244 | * 245 | * @description 246 | * Sets route definition that will be used on route change when no other route definition 247 | * is matched. 248 | * 249 | * @param {Object|string} params Mapping information to be assigned to `$route.current`. 250 | * If called with a string, the value maps to `redirectTo`. 251 | * @returns {Object} self 252 | */ 253 | this.otherwise = function(params) { 254 | if (typeof params === 'string') { 255 | params = {redirectTo: params}; 256 | } 257 | this.when(null, params); 258 | return this; 259 | }; 260 | 261 | 262 | this.$get = ['$rootScope', 263 | '$location', 264 | '$routeParams', 265 | '$q', 266 | '$injector', 267 | '$templateRequest', 268 | '$sce', 269 | function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce) { 270 | 271 | /** 272 | * @ngdoc service 273 | * @name $route 274 | * @requires $location 275 | * @requires $routeParams 276 | * 277 | * @property {Object} current Reference to the current route definition. 278 | * The route definition contains: 279 | * 280 | * - `controller`: The controller constructor as defined in the route definition. 281 | * - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for 282 | * controller instantiation. The `locals` contain 283 | * the resolved values of the `resolve` map. Additionally the `locals` also contain: 284 | * 285 | * - `$scope` - The current route scope. 286 | * - `$template` - The current route template HTML. 287 | * 288 | * The `locals` will be assigned to the route scope's `$resolve` property. You can override 289 | * the property name, using `resolveAs` in the route definition. See 290 | * {@link ngRoute.$routeProvider $routeProvider} for more info. 291 | * 292 | * @property {Object} routes Object with all route configuration Objects as its properties. 293 | * 294 | * @description 295 | * `$route` is used for deep-linking URLs to controllers and views (HTML partials). 296 | * It watches `$location.url()` and tries to map the path to an existing route definition. 297 | * 298 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 299 | * 300 | * You can define routes through {@link ngRoute.$routeProvider $routeProvider}'s API. 301 | * 302 | * The `$route` service is typically used in conjunction with the 303 | * {@link ngRoute.directive:ngView `ngView`} directive and the 304 | * {@link ngRoute.$routeParams `$routeParams`} service. 305 | * 306 | * @example 307 | * This example shows how changing the URL hash causes the `$route` to match a route against the 308 | * URL, and the `ngView` pulls in the partial. 309 | * 310 | * 312 | * 313 | *
314 | * Choose: 315 | * Moby | 316 | * Moby: Ch1 | 317 | * Gatsby | 318 | * Gatsby: Ch4 | 319 | * Scarlet Letter
320 | * 321 | *
322 | * 323 | *
324 | * 325 | *
$location.path() = {{$location.path()}}
326 | *
$route.current.templateUrl = {{$route.current.templateUrl}}
327 | *
$route.current.params = {{$route.current.params}}
328 | *
$route.current.scope.name = {{$route.current.scope.name}}
329 | *
$routeParams = {{$routeParams}}
330 | *
331 | *
332 | * 333 | * 334 | * controller: {{name}}
335 | * Book Id: {{params.bookId}}
336 | *
337 | * 338 | * 339 | * controller: {{name}}
340 | * Book Id: {{params.bookId}}
341 | * Chapter Id: {{params.chapterId}} 342 | *
343 | * 344 | * 345 | * angular.module('ngRouteExample', ['ngRoute']) 346 | * 347 | * .controller('MainController', function($scope, $route, $routeParams, $location) { 348 | * $scope.$route = $route; 349 | * $scope.$location = $location; 350 | * $scope.$routeParams = $routeParams; 351 | * }) 352 | * 353 | * .controller('BookController', function($scope, $routeParams) { 354 | * $scope.name = "BookController"; 355 | * $scope.params = $routeParams; 356 | * }) 357 | * 358 | * .controller('ChapterController', function($scope, $routeParams) { 359 | * $scope.name = "ChapterController"; 360 | * $scope.params = $routeParams; 361 | * }) 362 | * 363 | * .config(function($routeProvider, $locationProvider) { 364 | * $routeProvider 365 | * .when('/Book/:bookId', { 366 | * templateUrl: 'book.html', 367 | * controller: 'BookController', 368 | * resolve: { 369 | * // I will cause a 1 second delay 370 | * delay: function($q, $timeout) { 371 | * var delay = $q.defer(); 372 | * $timeout(delay.resolve, 1000); 373 | * return delay.promise; 374 | * } 375 | * } 376 | * }) 377 | * .when('/Book/:bookId/ch/:chapterId', { 378 | * templateUrl: 'chapter.html', 379 | * controller: 'ChapterController' 380 | * }); 381 | * 382 | * // configure html5 to get links working on jsfiddle 383 | * $locationProvider.html5Mode(true); 384 | * }); 385 | * 386 | * 387 | * 388 | * 389 | * it('should load and compile correct template', function() { 390 | * element(by.linkText('Moby: Ch1')).click(); 391 | * var content = element(by.css('[ng-view]')).getText(); 392 | * expect(content).toMatch(/controller\: ChapterController/); 393 | * expect(content).toMatch(/Book Id\: Moby/); 394 | * expect(content).toMatch(/Chapter Id\: 1/); 395 | * 396 | * element(by.partialLinkText('Scarlet')).click(); 397 | * 398 | * content = element(by.css('[ng-view]')).getText(); 399 | * expect(content).toMatch(/controller\: BookController/); 400 | * expect(content).toMatch(/Book Id\: Scarlet/); 401 | * }); 402 | * 403 | *
404 | */ 405 | 406 | /** 407 | * @ngdoc event 408 | * @name $route#$routeChangeStart 409 | * @eventType broadcast on root scope 410 | * @description 411 | * Broadcasted before a route change. At this point the route services starts 412 | * resolving all of the dependencies needed for the route change to occur. 413 | * Typically this involves fetching the view template as well as any dependencies 414 | * defined in `resolve` route property. Once all of the dependencies are resolved 415 | * `$routeChangeSuccess` is fired. 416 | * 417 | * The route change (and the `$location` change that triggered it) can be prevented 418 | * by calling `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on} 419 | * for more details about event object. 420 | * 421 | * @param {Object} angularEvent Synthetic event object. 422 | * @param {Route} next Future route information. 423 | * @param {Route} current Current route information. 424 | */ 425 | 426 | /** 427 | * @ngdoc event 428 | * @name $route#$routeChangeSuccess 429 | * @eventType broadcast on root scope 430 | * @description 431 | * Broadcasted after a route change has happened successfully. 432 | * The `resolve` dependencies are now available in the `current.locals` property. 433 | * 434 | * {@link ngRoute.directive:ngView ngView} listens for the directive 435 | * to instantiate the controller and render the view. 436 | * 437 | * @param {Object} angularEvent Synthetic event object. 438 | * @param {Route} current Current route information. 439 | * @param {Route|Undefined} previous Previous route information, or undefined if current is 440 | * first route entered. 441 | */ 442 | 443 | /** 444 | * @ngdoc event 445 | * @name $route#$routeChangeError 446 | * @eventType broadcast on root scope 447 | * @description 448 | * Broadcasted if any of the resolve promises are rejected. 449 | * 450 | * @param {Object} angularEvent Synthetic event object 451 | * @param {Route} current Current route information. 452 | * @param {Route} previous Previous route information. 453 | * @param {Route} rejection Rejection of the promise. Usually the error of the failed promise. 454 | */ 455 | 456 | /** 457 | * @ngdoc event 458 | * @name $route#$routeUpdate 459 | * @eventType broadcast on root scope 460 | * @description 461 | * The `reloadOnSearch` property has been set to false, and we are reusing the same 462 | * instance of the Controller. 463 | * 464 | * @param {Object} angularEvent Synthetic event object 465 | * @param {Route} current Current/previous route information. 466 | */ 467 | 468 | var forceReload = false, 469 | preparedRoute, 470 | preparedRouteIsUpdateOnly, 471 | $route = { 472 | routes: routes, 473 | 474 | /** 475 | * @ngdoc method 476 | * @name $route#reload 477 | * 478 | * @description 479 | * Causes `$route` service to reload the current route even if 480 | * {@link ng.$location $location} hasn't changed. 481 | * 482 | * As a result of that, {@link ngRoute.directive:ngView ngView} 483 | * creates new scope and reinstantiates the controller. 484 | */ 485 | reload: function() { 486 | forceReload = true; 487 | 488 | var fakeLocationEvent = { 489 | defaultPrevented: false, 490 | preventDefault: function fakePreventDefault() { 491 | this.defaultPrevented = true; 492 | forceReload = false; 493 | } 494 | }; 495 | 496 | $rootScope.$evalAsync(function() { 497 | prepareRoute(fakeLocationEvent); 498 | if (!fakeLocationEvent.defaultPrevented) commitRoute(); 499 | }); 500 | }, 501 | 502 | /** 503 | * @ngdoc method 504 | * @name $route#updateParams 505 | * 506 | * @description 507 | * Causes `$route` service to update the current URL, replacing 508 | * current route parameters with those specified in `newParams`. 509 | * Provided property names that match the route's path segment 510 | * definitions will be interpolated into the location's path, while 511 | * remaining properties will be treated as query params. 512 | * 513 | * @param {!Object} newParams mapping of URL parameter names to values 514 | */ 515 | updateParams: function(newParams) { 516 | if (this.current && this.current.$$route) { 517 | newParams = angular.extend({}, this.current.params, newParams); 518 | $location.path(interpolate(this.current.$$route.originalPath, newParams)); 519 | // interpolate modifies newParams, only query params are left 520 | $location.search(newParams); 521 | } else { 522 | throw $routeMinErr('norout', 'Tried updating route when with no current route'); 523 | } 524 | } 525 | }; 526 | 527 | $rootScope.$on('$locationChangeStart', prepareRoute); 528 | $rootScope.$on('$locationChangeSuccess', commitRoute); 529 | 530 | return $route; 531 | 532 | ///////////////////////////////////////////////////// 533 | 534 | /** 535 | * @param on {string} current url 536 | * @param route {Object} route regexp to match the url against 537 | * @return {?Object} 538 | * 539 | * @description 540 | * Check if the route matches the current url. 541 | * 542 | * Inspired by match in 543 | * visionmedia/express/lib/router/router.js. 544 | */ 545 | function switchRouteMatcher(on, route) { 546 | var keys = route.keys, 547 | params = {}; 548 | 549 | if (!route.regexp) return null; 550 | 551 | var m = route.regexp.exec(on); 552 | if (!m) return null; 553 | 554 | for (var i = 1, len = m.length; i < len; ++i) { 555 | var key = keys[i - 1]; 556 | 557 | var val = m[i]; 558 | 559 | if (key && val) { 560 | params[key.name] = val; 561 | } 562 | } 563 | return params; 564 | } 565 | 566 | function prepareRoute($locationEvent) { 567 | var lastRoute = $route.current; 568 | 569 | preparedRoute = parseRoute(); 570 | preparedRouteIsUpdateOnly = preparedRoute && lastRoute && preparedRoute.$$route === lastRoute.$$route 571 | && angular.equals(preparedRoute.pathParams, lastRoute.pathParams) 572 | && !preparedRoute.reloadOnSearch && !forceReload; 573 | 574 | if (!preparedRouteIsUpdateOnly && (lastRoute || preparedRoute)) { 575 | if ($rootScope.$broadcast('$routeChangeStart', preparedRoute, lastRoute).defaultPrevented) { 576 | if ($locationEvent) { 577 | $locationEvent.preventDefault(); 578 | } 579 | } 580 | } 581 | } 582 | 583 | function commitRoute() { 584 | var lastRoute = $route.current; 585 | var nextRoute = preparedRoute; 586 | 587 | if (preparedRouteIsUpdateOnly) { 588 | lastRoute.params = nextRoute.params; 589 | angular.copy(lastRoute.params, $routeParams); 590 | $rootScope.$broadcast('$routeUpdate', lastRoute); 591 | } else if (nextRoute || lastRoute) { 592 | forceReload = false; 593 | $route.current = nextRoute; 594 | if (nextRoute) { 595 | if (nextRoute.redirectTo) { 596 | if (angular.isString(nextRoute.redirectTo)) { 597 | $location.path(interpolate(nextRoute.redirectTo, nextRoute.params)).search(nextRoute.params) 598 | .replace(); 599 | } else { 600 | $location.url(nextRoute.redirectTo(nextRoute.pathParams, $location.path(), $location.search())) 601 | .replace(); 602 | } 603 | } 604 | } 605 | 606 | $q.when(nextRoute). 607 | then(function() { 608 | if (nextRoute) { 609 | var locals = angular.extend({}, nextRoute.resolve), 610 | template, templateUrl; 611 | 612 | angular.forEach(locals, function(value, key) { 613 | locals[key] = angular.isString(value) ? 614 | $injector.get(value) : $injector.invoke(value, null, null, key); 615 | }); 616 | 617 | if (angular.isDefined(template = nextRoute.template)) { 618 | if (angular.isFunction(template)) { 619 | template = template(nextRoute.params); 620 | } 621 | } else if (angular.isDefined(templateUrl = nextRoute.templateUrl)) { 622 | if (angular.isFunction(templateUrl)) { 623 | templateUrl = templateUrl(nextRoute.params); 624 | } 625 | if (angular.isDefined(templateUrl)) { 626 | nextRoute.loadedTemplateUrl = $sce.valueOf(templateUrl); 627 | template = $templateRequest(templateUrl); 628 | } 629 | } 630 | if (angular.isDefined(template)) { 631 | locals['$template'] = template; 632 | } 633 | return $q.all(locals); 634 | } 635 | }). 636 | then(function(locals) { 637 | // after route change 638 | if (nextRoute == $route.current) { 639 | if (nextRoute) { 640 | nextRoute.locals = locals; 641 | angular.copy(nextRoute.params, $routeParams); 642 | } 643 | $rootScope.$broadcast('$routeChangeSuccess', nextRoute, lastRoute); 644 | } 645 | }, function(error) { 646 | if (nextRoute == $route.current) { 647 | $rootScope.$broadcast('$routeChangeError', nextRoute, lastRoute, error); 648 | } 649 | }); 650 | } 651 | } 652 | 653 | 654 | /** 655 | * @returns {Object} the current active route, by matching it against the URL 656 | */ 657 | function parseRoute() { 658 | // Match a route 659 | var params, match; 660 | angular.forEach(routes, function(route, path) { 661 | if (!match && (params = switchRouteMatcher($location.path(), route))) { 662 | match = inherit(route, { 663 | params: angular.extend({}, $location.search(), params), 664 | pathParams: params}); 665 | match.$$route = route; 666 | } 667 | }); 668 | // No route matched; fallback to "otherwise" route 669 | return match || routes[null] && inherit(routes[null], {params: {}, pathParams:{}}); 670 | } 671 | 672 | /** 673 | * @returns {string} interpolation of the redirect path with the parameters 674 | */ 675 | function interpolate(string, params) { 676 | var result = []; 677 | angular.forEach((string || '').split(':'), function(segment, i) { 678 | if (i === 0) { 679 | result.push(segment); 680 | } else { 681 | var segmentMatch = segment.match(/(\w+)(?:[?*])?(.*)/); 682 | var key = segmentMatch[1]; 683 | result.push(params[key]); 684 | result.push(segmentMatch[2] || ''); 685 | delete params[key]; 686 | } 687 | }); 688 | return result.join(''); 689 | } 690 | }]; 691 | } 692 | 693 | ngRouteModule.provider('$routeParams', $RouteParamsProvider); 694 | 695 | 696 | /** 697 | * @ngdoc service 698 | * @name $routeParams 699 | * @requires $route 700 | * 701 | * @description 702 | * The `$routeParams` service allows you to retrieve the current set of route parameters. 703 | * 704 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 705 | * 706 | * The route parameters are a combination of {@link ng.$location `$location`}'s 707 | * {@link ng.$location#search `search()`} and {@link ng.$location#path `path()`}. 708 | * The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched. 709 | * 710 | * In case of parameter name collision, `path` params take precedence over `search` params. 711 | * 712 | * The service guarantees that the identity of the `$routeParams` object will remain unchanged 713 | * (but its properties will likely change) even when a route change occurs. 714 | * 715 | * Note that the `$routeParams` are only updated *after* a route change completes successfully. 716 | * This means that you cannot rely on `$routeParams` being correct in route resolve functions. 717 | * Instead you can use `$route.current.params` to access the new route's parameters. 718 | * 719 | * @example 720 | * ```js 721 | * // Given: 722 | * // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby 723 | * // Route: /Chapter/:chapterId/Section/:sectionId 724 | * // 725 | * // Then 726 | * $routeParams ==> {chapterId:'1', sectionId:'2', search:'moby'} 727 | * ``` 728 | */ 729 | function $RouteParamsProvider() { 730 | this.$get = function() { return {}; }; 731 | } 732 | 733 | ngRouteModule.directive('ngView', ngViewFactory); 734 | ngRouteModule.directive('ngView', ngViewFillContentFactory); 735 | 736 | 737 | /** 738 | * @ngdoc directive 739 | * @name ngView 740 | * @restrict ECA 741 | * 742 | * @description 743 | * # Overview 744 | * `ngView` is a directive that complements the {@link ngRoute.$route $route} service by 745 | * including the rendered template of the current route into the main layout (`index.html`) file. 746 | * Every time the current route changes, the included view changes with it according to the 747 | * configuration of the `$route` service. 748 | * 749 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 750 | * 751 | * @animations 752 | * | Animation | Occurs | 753 | * |----------------------------------|-------------------------------------| 754 | * | {@link ng.$animate#enter enter} | when the new element is inserted to the DOM | 755 | * | {@link ng.$animate#leave leave} | when the old element is removed from to the DOM | 756 | * 757 | * The enter and leave animation occur concurrently. 758 | * 759 | * @knownIssue If `ngView` is contained in an asynchronously loaded template (e.g. in another 760 | * directive's templateUrl or in a template loaded using `ngInclude`), then you need to 761 | * make sure that `$route` is instantiated in time to capture the initial 762 | * `$locationChangeStart` event and load the appropriate view. One way to achieve this 763 | * is to have it as a dependency in a `.run` block: 764 | * `myModule.run(['$route', function() {}]);` 765 | * 766 | * @scope 767 | * @priority 400 768 | * @param {string=} onload Expression to evaluate whenever the view updates. 769 | * 770 | * @param {string=} autoscroll Whether `ngView` should call {@link ng.$anchorScroll 771 | * $anchorScroll} to scroll the viewport after the view is updated. 772 | * 773 | * - If the attribute is not set, disable scrolling. 774 | * - If the attribute is set without value, enable scrolling. 775 | * - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated 776 | * as an expression yields a truthy value. 777 | * @example 778 | 781 | 782 |
783 | Choose: 784 | Moby | 785 | Moby: Ch1 | 786 | Gatsby | 787 | Gatsby: Ch4 | 788 | Scarlet Letter
789 | 790 |
791 |
792 |
793 |
794 | 795 |
$location.path() = {{main.$location.path()}}
796 |
$route.current.templateUrl = {{main.$route.current.templateUrl}}
797 |
$route.current.params = {{main.$route.current.params}}
798 |
$routeParams = {{main.$routeParams}}
799 |
800 |
801 | 802 | 803 |
804 | controller: {{book.name}}
805 | Book Id: {{book.params.bookId}}
806 |
807 |
808 | 809 | 810 |
811 | controller: {{chapter.name}}
812 | Book Id: {{chapter.params.bookId}}
813 | Chapter Id: {{chapter.params.chapterId}} 814 |
815 |
816 | 817 | 818 | .view-animate-container { 819 | position:relative; 820 | height:100px!important; 821 | background:white; 822 | border:1px solid black; 823 | height:40px; 824 | overflow:hidden; 825 | } 826 | 827 | .view-animate { 828 | padding:10px; 829 | } 830 | 831 | .view-animate.ng-enter, .view-animate.ng-leave { 832 | transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s; 833 | 834 | display:block; 835 | width:100%; 836 | border-left:1px solid black; 837 | 838 | position:absolute; 839 | top:0; 840 | left:0; 841 | right:0; 842 | bottom:0; 843 | padding:10px; 844 | } 845 | 846 | .view-animate.ng-enter { 847 | left:100%; 848 | } 849 | .view-animate.ng-enter.ng-enter-active { 850 | left:0; 851 | } 852 | .view-animate.ng-leave.ng-leave-active { 853 | left:-100%; 854 | } 855 | 856 | 857 | 858 | angular.module('ngViewExample', ['ngRoute', 'ngAnimate']) 859 | .config(['$routeProvider', '$locationProvider', 860 | function($routeProvider, $locationProvider) { 861 | $routeProvider 862 | .when('/Book/:bookId', { 863 | templateUrl: 'book.html', 864 | controller: 'BookCtrl', 865 | controllerAs: 'book' 866 | }) 867 | .when('/Book/:bookId/ch/:chapterId', { 868 | templateUrl: 'chapter.html', 869 | controller: 'ChapterCtrl', 870 | controllerAs: 'chapter' 871 | }); 872 | 873 | $locationProvider.html5Mode(true); 874 | }]) 875 | .controller('MainCtrl', ['$route', '$routeParams', '$location', 876 | function($route, $routeParams, $location) { 877 | this.$route = $route; 878 | this.$location = $location; 879 | this.$routeParams = $routeParams; 880 | }]) 881 | .controller('BookCtrl', ['$routeParams', function($routeParams) { 882 | this.name = "BookCtrl"; 883 | this.params = $routeParams; 884 | }]) 885 | .controller('ChapterCtrl', ['$routeParams', function($routeParams) { 886 | this.name = "ChapterCtrl"; 887 | this.params = $routeParams; 888 | }]); 889 | 890 | 891 | 892 | 893 | it('should load and compile correct template', function() { 894 | element(by.linkText('Moby: Ch1')).click(); 895 | var content = element(by.css('[ng-view]')).getText(); 896 | expect(content).toMatch(/controller\: ChapterCtrl/); 897 | expect(content).toMatch(/Book Id\: Moby/); 898 | expect(content).toMatch(/Chapter Id\: 1/); 899 | 900 | element(by.partialLinkText('Scarlet')).click(); 901 | 902 | content = element(by.css('[ng-view]')).getText(); 903 | expect(content).toMatch(/controller\: BookCtrl/); 904 | expect(content).toMatch(/Book Id\: Scarlet/); 905 | }); 906 | 907 |
908 | */ 909 | 910 | 911 | /** 912 | * @ngdoc event 913 | * @name ngView#$viewContentLoaded 914 | * @eventType emit on the current ngView scope 915 | * @description 916 | * Emitted every time the ngView content is reloaded. 917 | */ 918 | ngViewFactory.$inject = ['$route', '$anchorScroll', '$animate']; 919 | function ngViewFactory($route, $anchorScroll, $animate) { 920 | return { 921 | restrict: 'ECA', 922 | terminal: true, 923 | priority: 400, 924 | transclude: 'element', 925 | link: function(scope, $element, attr, ctrl, $transclude) { 926 | var currentScope, 927 | currentElement, 928 | previousLeaveAnimation, 929 | autoScrollExp = attr.autoscroll, 930 | onloadExp = attr.onload || ''; 931 | 932 | scope.$on('$routeChangeSuccess', update); 933 | update(); 934 | 935 | function cleanupLastView() { 936 | if (previousLeaveAnimation) { 937 | $animate.cancel(previousLeaveAnimation); 938 | previousLeaveAnimation = null; 939 | } 940 | 941 | if (currentScope) { 942 | currentScope.$destroy(); 943 | currentScope = null; 944 | } 945 | if (currentElement) { 946 | previousLeaveAnimation = $animate.leave(currentElement); 947 | previousLeaveAnimation.then(function() { 948 | previousLeaveAnimation = null; 949 | }); 950 | currentElement = null; 951 | } 952 | } 953 | 954 | function update() { 955 | var locals = $route.current && $route.current.locals, 956 | template = locals && locals.$template; 957 | 958 | if (angular.isDefined(template)) { 959 | var newScope = scope.$new(); 960 | var current = $route.current; 961 | 962 | // Note: This will also link all children of ng-view that were contained in the original 963 | // html. If that content contains controllers, ... they could pollute/change the scope. 964 | // However, using ng-view on an element with additional content does not make sense... 965 | // Note: We can't remove them in the cloneAttchFn of $transclude as that 966 | // function is called before linking the content, which would apply child 967 | // directives to non existing elements. 968 | var clone = $transclude(newScope, function(clone) { 969 | $animate.enter(clone, null, currentElement || $element).then(function onNgViewEnter() { 970 | if (angular.isDefined(autoScrollExp) 971 | && (!autoScrollExp || scope.$eval(autoScrollExp))) { 972 | $anchorScroll(); 973 | } 974 | }); 975 | cleanupLastView(); 976 | }); 977 | 978 | currentElement = clone; 979 | currentScope = current.scope = newScope; 980 | currentScope.$emit('$viewContentLoaded'); 981 | currentScope.$eval(onloadExp); 982 | } else { 983 | cleanupLastView(); 984 | } 985 | } 986 | } 987 | }; 988 | } 989 | 990 | // This directive is called during the $transclude call of the first `ngView` directive. 991 | // It will replace and compile the content of the element with the loaded template. 992 | // We need this directive so that the element content is already filled when 993 | // the link function of another directive on the same element as ngView 994 | // is called. 995 | ngViewFillContentFactory.$inject = ['$compile', '$controller', '$route']; 996 | function ngViewFillContentFactory($compile, $controller, $route) { 997 | return { 998 | restrict: 'ECA', 999 | priority: -400, 1000 | link: function(scope, $element) { 1001 | var current = $route.current, 1002 | locals = current.locals; 1003 | 1004 | $element.html(locals.$template); 1005 | 1006 | var link = $compile($element.contents()); 1007 | 1008 | if (current.controller) { 1009 | locals.$scope = scope; 1010 | var controller = $controller(current.controller, locals); 1011 | if (current.controllerAs) { 1012 | scope[current.controllerAs] = controller; 1013 | } 1014 | $element.data('$ngControllerController', controller); 1015 | $element.children().data('$ngControllerController', controller); 1016 | } 1017 | scope[current.resolveAs || '$resolve'] = locals; 1018 | 1019 | link(scope); 1020 | } 1021 | }; 1022 | } 1023 | 1024 | 1025 | })(window, window.angular); 1026 | -------------------------------------------------------------------------------- /src/main/resources/static/js/app.js: -------------------------------------------------------------------------------- 1 | var nanoproxy = angular.module('nanoproxy', ['ngRoute','ui.materialize','pageslide-directive','chart.js']) 2 | 3 | nanoproxy.config(function ($routeProvider, $httpProvider) { 4 | $routeProvider 5 | .when('/', { 6 | templateUrl: 'views/home.html', 7 | controller: 'home' 8 | }).when('/proxy/:id',{ 9 | templateUrl: 'views/proxy.html', 10 | controller: 'proxy' 11 | }) 12 | $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 13 | }); -------------------------------------------------------------------------------- /src/main/resources/static/js/home.js: -------------------------------------------------------------------------------- 1 | var nanoproxy = angular.module('nanoproxy'); 2 | 3 | nanoproxy.controller('home',function($scope, $http){ 4 | $scope.proxies = []; 5 | $scope.addProxy = function(){ 6 | $http.post('/servers',$scope.proxy).then(function success(response){ 7 | $scope.proxies.push(response.data); 8 | $scope.proxy = {}; 9 | $scope.proxyForm.$setPristine(); 10 | $scope.$apply(); 11 | }, 12 | function error(response){ 13 | console.error(response); 14 | }); 15 | } 16 | $http.get("/servers").then(function success(response){ 17 | angular.forEach(response.data,function(p,key){ 18 | $scope.proxies.push(p); 19 | }, function error(response){ 20 | 21 | }) 22 | }); 23 | 24 | }); -------------------------------------------------------------------------------- /src/main/resources/static/js/proxy.js: -------------------------------------------------------------------------------- 1 | var nanoproxy = angular.module('nanoproxy'); 2 | nanoproxy.controller('proxy', function($scope, $routeParams, $http, $interval){ 3 | 4 | $scope.promise = {} 5 | $scope.stats = {} 6 | $scope.last = {} 7 | $scope.console = false; 8 | $scope.received =[[]]; 9 | $scope.sent = [[]]; 10 | $scope.labels= []; 11 | $scope.series = ['Bytes Received']; 12 | $scope.sentColors = [{ // dark grey 13 | fillColor: 'rgba(208,12,9,0.2)', 14 | strokeColor: 'rgba(208,12,9,1)', 15 | pointColor: 'rgba(208,12,9,1)', 16 | pointStrokeColor: '#fff', 17 | pointHighlightFill: '#fff', 18 | pointHighlightStroke: 'rgba(208,12,9,1)' 19 | }] 20 | $scope.maxPoints = 100; 21 | $scope.options = { 22 | animation: false, 23 | showScale: true, 24 | showTooltips: false, 25 | pointDot: false, 26 | datasetStrokeWidth: 0.5 27 | }; 28 | 29 | $http.get('/servers/'+$routeParams.id).then(function success(response){ 30 | $scope.proxy = response.data; 31 | 32 | }, function error(response){ 33 | console.error(response); 34 | }); 35 | 36 | $scope.updateStats = function(){ 37 | $http.get('/servers/'+$scope.proxy.id+'/stats').then(function success(response){ 38 | 39 | if($scope.received.length && $scope.received[0].length >= $scope.maxPoints){ 40 | $scope.labels = $scope.labels.slice(1); 41 | $scope.sent[0] = $scope.sent[0].slice(1); 42 | $scope.received[0] = $scope.received[0].slice(1); 43 | } 44 | 45 | if(typeof $scope.last.bytesSent != 'undefined'){ 46 | stats = response.data; 47 | deltaReceived = stats.bytesReceived - $scope.last.bytesReceived; 48 | deltaSent = stats.bytesSent - $scope.last.bytesSent; 49 | $scope.labels.push(''); 50 | $scope.received[0].push(stats.bytesReceived/1024); 51 | $scope.sent[0].push(stats.bytesSent/1024); 52 | } 53 | 54 | $scope.last = response.data; 55 | 56 | }, function error(response){ 57 | console.error(response); 58 | $interval.cancel($scope.promise); 59 | }); 60 | } 61 | 62 | $scope.toggleStatus = function($event){ 63 | $http.post('/servers/'+$scope.proxy.id+'/status',{active: $event}).then(function success(response){ 64 | 65 | }, function error(response){ 66 | console.error(response); 67 | }); 68 | } 69 | 70 | $scope.applyChanges = function(){ 71 | $http.post('/servers/'+$scope.proxy.id+'/traffic', $scope.proxy.qos.trafficShaping).then(function success(response){ 72 | 73 | },function error(response){ 74 | 75 | }); 76 | } 77 | 78 | $scope.promise = $interval(function(){$scope.updateStats()},1000); 79 | 80 | 81 | 82 | 83 | 84 | 85 | }); -------------------------------------------------------------------------------- /src/main/resources/static/views/home.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 10 |
11 |
12 | 13 | 14 |
15 |
16 | 17 | 18 |
19 |
20 | 21 | 22 |
23 |
24 | 25 | 26 |
27 |
28 | 29 |
30 |
31 |
32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 53 | 54 | 55 |
AliasLocal PortRemote HostRemote PortStatus
{{proxy.alias}}{{proxy.localPort}}{{proxy.remoteHost}}{{proxy.remotePort}} 50 |
51 |
52 |
56 |
57 | 58 | -------------------------------------------------------------------------------- /src/main/resources/static/views/proxy.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
Overview
4 |
5 |
6 |
7 | 13 |
14 |
15 |
16 |
17 |
18 |
{{proxy.alias}} @ {{proxy.remotePort}}
19 |
20 |
21 |
remote host: {{proxy.remoteHost}} @ {{proxy.remotePort}}
22 |
23 |
24 |
25 |
26 | 27 |
28 |
29 | 30 |
31 |
32 |
33 |
Bytes received (Kb)
34 |
Bytes sent (Kb)
35 |
36 |
37 |
38 |
39 |
40 |
QoS
41 |
42 |
filter_dramaTraffic Shapping
43 |
44 |
45 | 46 | 47 |
48 |
49 | 50 | 51 |
52 |
53 | 54 |
55 |
56 |
57 |
58 |
59 | 60 |
61 | 62 | -------------------------------------------------------------------------------- /src/test/java/io/igx/proxy/TcpProxyApplicationTests.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy; 2 | 3 | import io.igx.proxy.domain.CreateProxyRequest; 4 | import io.igx.proxy.domain.ProxyDefinition; 5 | import io.igx.proxy.domain.TrafficShaping; 6 | import io.igx.proxy.services.NettyServerService; 7 | import io.igx.proxy.services.NettyServerServiceImpl; 8 | import org.junit.Test; 9 | 10 | public class TcpProxyApplicationTests { 11 | 12 | @Test 13 | public void testTrafficShapping() throws Exception{ 14 | NettyServerService service = new NettyServerServiceImpl(); 15 | ProxyDefinition proxyDefinition = new ProxyDefinition(new CreateProxyRequest()); 16 | proxyDefinition.setLocalPort(16001); 17 | proxyDefinition.setRemoteHost("localhost"); 18 | proxyDefinition.setRemotePort(5672); 19 | proxyDefinition.getQos().setTrafficShaping(new TrafficShaping(1_000l,1_000l)); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/io/igx/proxy/TrafficGeneratorClientHandler.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.channel.SimpleChannelInboundHandler; 6 | 7 | /** 8 | * @author Vinicius Carvalho 9 | */ 10 | public class TrafficGeneratorClientHandler extends SimpleChannelInboundHandler { 11 | 12 | private ChannelHandlerContext ctx; 13 | 14 | @Override 15 | public void channelActive(ChannelHandlerContext ctx) throws Exception { 16 | this.ctx = ctx; 17 | 18 | } 19 | 20 | @Override 21 | protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { 22 | 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/io/igx/proxy/TrafficSimulationTests.java: -------------------------------------------------------------------------------- 1 | package io.igx.proxy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Random; 6 | import java.util.concurrent.CountDownLatch; 7 | import java.util.concurrent.ExecutorService; 8 | import java.util.concurrent.Executors; 9 | 10 | import io.netty.bootstrap.Bootstrap; 11 | import io.netty.buffer.ByteBuf; 12 | import io.netty.buffer.Unpooled; 13 | import io.netty.channel.Channel; 14 | import io.netty.channel.ChannelFuture; 15 | import io.netty.channel.ChannelFutureListener; 16 | import io.netty.channel.nio.NioEventLoopGroup; 17 | import io.netty.channel.socket.nio.NioSocketChannel; 18 | import org.junit.Test; 19 | 20 | /** 21 | * @author Vinicius Carvalho 22 | */ 23 | public class TrafficSimulationTests { 24 | 25 | @Test 26 | public void runSimulation() throws Exception{ 27 | TrafficSimulator simulator = new TrafficSimulator(300); 28 | simulator.connect("localhost",8008); 29 | simulator.run(); 30 | } 31 | 32 | @Test 33 | public void simple() throws Exception { 34 | Bootstrap bootstrap = new Bootstrap(); 35 | bootstrap.group(new NioEventLoopGroup(1)) 36 | .channel(NioSocketChannel.class) 37 | .handler(new TrafficGeneratorClientHandler()); 38 | final CountDownLatch latch = new CountDownLatch(1); 39 | bootstrap.connect("localhost",8010).addListener(new ChannelFutureListener() { 40 | @Override 41 | public void operationComplete(ChannelFuture future) throws Exception { 42 | if(future.isSuccess()){ 43 | future.channel().writeAndFlush(Unpooled.buffer().capacity(256).writeZero(256)); 44 | }else { 45 | System.err.println("Connection attempt failed"); 46 | future.cause().printStackTrace(); 47 | } 48 | latch.countDown(); 49 | } 50 | }); 51 | 52 | latch.await(); 53 | 54 | } 55 | 56 | public static class TrafficSimulator { 57 | 58 | private long runningTime; 59 | private Bootstrap bootstrap; 60 | private Channel channel; 61 | private Integer[] sizes = new Integer[]{512,1024,2048,4096,8192,16384}; 62 | private Random random = new Random(); 63 | 64 | public TrafficSimulator(long runningTime) { 65 | this.runningTime = runningTime; 66 | } 67 | 68 | 69 | public void connect(String host, int port) throws Exception{ 70 | this.bootstrap = new Bootstrap(); 71 | final CountDownLatch latch = new CountDownLatch(1); 72 | bootstrap.group(new NioEventLoopGroup(1)) 73 | .channel(NioSocketChannel.class) 74 | .handler(new TrafficGeneratorClientHandler()); 75 | System.out.println("Creating connection"); 76 | ChannelFuture cf = bootstrap.connect(host,port); 77 | cf.addListener(new ChannelFutureListener() { 78 | @Override 79 | public void operationComplete(ChannelFuture future) throws Exception { 80 | System.out.println("Connected"); 81 | if (future.isSuccess()) { 82 | channel = future.channel(); 83 | } else { 84 | future.cause().printStackTrace(); 85 | future.channel().close(); 86 | throw new RuntimeException(future.cause()); 87 | } 88 | latch.countDown(); 89 | } 90 | }); 91 | latch.await(); 92 | } 93 | 94 | 95 | public void run() throws Exception{ 96 | Long stop = (runningTime*1000) + System.currentTimeMillis(); 97 | while(stop - System.currentTimeMillis() > 0){ 98 | int size = sizes[random.nextInt(sizes.length)]; 99 | channel.writeAndFlush(Unpooled.buffer().capacity(size).writeZero(size)); 100 | Thread.sleep(10L); 101 | } 102 | } 103 | 104 | 105 | } 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | } 115 | 116 | --------------------------------------------------------------------------------