save
Showing
42 changed files
with
438 additions
and
0 deletions
No preview for this file type
| 1 | 6e748c16d9079ce336611a59b511a693 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 60f8b8f393c8e7473c414f67fd4c0b33006d0ea1 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>proxymanager</artifactId> | ||
| 7 | <version>1.0</version> | ||
| 8 | </project> |
| 1 | d01ad073eb3c61bddaf90f21f8fb5e75 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | c66ba2702c2a8a69db61929a82cdf400183083df | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | ecba97cfde9cdb328b90997bc3506f82 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | aa443ffb1efe591c851713884f0c5e66cf09dc01 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>proxymanager</artifactId> | ||
| 7 | <version>1.1</version> | ||
| 8 | </project> |
| 1 | 349be90bd54764dcaff9132517c4394c | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 9781a7bcd3d9bea91d36c86db1e69f82f5565ec5 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | 8f34d0021feb122ba45a98947498e41e | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 4e7c2284eee3ca7a23acb7af05b1e93fac8202d7 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>proxymanager</artifactId> | ||
| 7 | <version>1.2</version> | ||
| 8 | </project> |
| 1 | 00d5b514394541b928d99955c6abd262 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 06fac3ddaa808258e618750132127adf72225f91 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | e4581e795b0be4fe7d996dc4e4706b74 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 7b2d2f13d18e612abc690d13e7274bdb1d4468f9 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>proxymanager</artifactId> | ||
| 7 | <version>1.3</version> | ||
| 8 | </project> |
| 1 | 5d77f14f1fb8d29b1d39da5eb0a87ace | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | b7f6771336e7598032f3341463d4f1c8cc508946 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | 2c45f14dab6c4d905d4fceb1484b1956 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | e644cf48f61d417c71f53dc3990c5c8086b80d42 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>proxymanager</artifactId> | ||
| 7 | <version>1.4</version> | ||
| 8 | </project> |
| 1 | 4651b3978331f8c656d429c9aa6a89d8 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 7751ffe63a1e1d7d9a7997111d449f2ff697b3fb | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
No preview for this file type
| 1 | 3b8ca22c5c933274bbeb897ee5e02306 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | ff438544989c58e28f02ee3b5b3ee2be81563321 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 4 | <modelVersion>4.0.0</modelVersion> | ||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>proxymanager</artifactId> | ||
| 7 | <version>1.5</version> | ||
| 8 | </project> |
| 1 | 6b33a2fc800d3fc8a28a9565ba974db6 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 157f839ee31faa1ea298cfbeddc3c9957285bc01 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <metadata> | ||
| 3 | <groupId>org.emercit</groupId> | ||
| 4 | <artifactId>proxymanager</artifactId> | ||
| 5 | <versioning> | ||
| 6 | <release>1.5</release> | ||
| 7 | <versions> | ||
| 8 | <version>1.0</version> | ||
| 9 | <version>1.1</version> | ||
| 10 | <version>1.2</version> | ||
| 11 | <version>1.3</version> | ||
| 12 | <version>1.4</version> | ||
| 13 | <version>1.5</version> | ||
| 14 | </versions> | ||
| 15 | <lastUpdated>20150716092042</lastUpdated> | ||
| 16 | </versioning> | ||
| 17 | </metadata> |
| 1 | 3310adccea01105b5f5ef7361679cf7d | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | 375d779bcb432886a15cc7e0f4441f09ac7e8be4 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.devtools.app; | ||
| 2 | |||
| 3 | |||
| 4 | import java.util.Locale; | ||
| 5 | |||
| 6 | import org.slf4j.Logger; | ||
| 7 | import org.slf4j.LoggerFactory; | ||
| 8 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 9 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 10 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | |||
| 12 | import javax.servlet.http.*; | ||
| 13 | import javax.servlet.ServletContext; | ||
| 14 | |||
| 15 | import java.io.*; | ||
| 16 | |||
| 17 | import org.springframework.stereotype.Controller; | ||
| 18 | import org.springframework.validation.BindingResult; | ||
| 19 | import org.springframework.web.bind.annotation.ModelAttribute; | ||
| 20 | import org.springframework.web.bind.annotation.PathVariable; | ||
| 21 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 22 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 23 | import org.springframework.web.bind.annotation.RequestParam; | ||
| 24 | import org.springframework.stereotype.Controller; | ||
| 25 | import org.springframework.web.bind.annotation.RequestMapping; | ||
| 26 | import org.springframework.web.bind.annotation.RequestMethod; | ||
| 27 | import org.springframework.web.bind.annotation.ResponseBody; | ||
| 28 | import org.springframework.web.bind.annotation.RequestBody; | ||
| 29 | |||
| 30 | import java.util.Vector; | ||
| 31 | |||
| 32 | import org.emercit.proxymanager.model.ProxyBean; | ||
| 33 | import org.emercit.devtools.service.DnsService; | ||
| 34 | import org.emercit.devtools.service.ProxyService; | ||
| 35 | import org.emercit.dnsmanager.model.DnsBean; | ||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | @Controller | ||
| 40 | @RequestMapping("api") | ||
| 41 | public class ProxyController { | ||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | @RequestMapping(value = "proxy/all", method = RequestMethod.GET) | ||
| 49 | public @ResponseBody Vector<ProxyBean> getAllProxy() { | ||
| 50 | |||
| 51 | try { | ||
| 52 | return ProxyService.INSTANCE.getAllProxyBean(); | ||
| 53 | } | ||
| 54 | catch(Exception e) | ||
| 55 | { | ||
| 56 | return null; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | |||
| 61 | @RequestMapping(value="proxy/update" , method = RequestMethod.POST) | ||
| 62 | public @ResponseBody boolean update(@RequestBody ProxyBean[] beans) { | ||
| 63 | |||
| 64 | |||
| 65 | Vector<ProxyBean> dbs=new Vector<ProxyBean>(); | ||
| 66 | |||
| 67 | for (ProxyBean d:beans) { | ||
| 68 | |||
| 69 | ProxyBean db=new ProxyBean(); | ||
| 70 | |||
| 71 | |||
| 72 | db.setId(d.getId()); | ||
| 73 | db.setProtocol(d.getProtocol()); | ||
| 74 | db.setHost(d.getHost()); | ||
| 75 | db.setPort(d.getPort()); | ||
| 76 | db.setLogin(d.getLogin()); | ||
| 77 | db.setPass(d.getPass()); | ||
| 78 | db.setEnabled(d.getEnabled()); | ||
| 79 | db.setAuth(d.getAuth()); | ||
| 80 | |||
| 81 | |||
| 82 | dbs.add(db); | ||
| 83 | } | ||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | return ProxyService.INSTANCE.Upd(dbs); | ||
| 88 | } | ||
| 89 | |||
| 90 | /* | ||
| 91 | export http_proxy='http://user:password@prox-server:3128' | ||
| 92 | export https_proxy='http://user:password@prox-server:3128' | ||
| 93 | export ftp_proxy='http://user:password@prox-server:3128' | ||
| 94 | |||
| 95 | */ | ||
| 96 | |||
| 97 | /* | ||
| 98 | * | ||
| 99 | */ | ||
| 100 | |||
| 101 | |||
| 102 | |||
| 103 | } | ||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 |
| 1 | package org.emercit.devtools.service; | ||
| 2 | |||
| 3 | |||
| 4 | import org.emercit.model.IPAddressValidator; | ||
| 5 | |||
| 6 | import java.util.Vector; | ||
| 7 | |||
| 8 | |||
| 9 | import org.emercit.proxymanager.model.ProxyBean; | ||
| 10 | import org.emercit.proxymanager.service.ProxyLinux; | ||
| 11 | import org.emercit.proxymanager.service.ProxyDBImpl; | ||
| 12 | |||
| 13 | |||
| 14 | public enum ProxyService { | ||
| 15 | |||
| 16 | INSTANCE; | ||
| 17 | |||
| 18 | private ProxyLinux proxylinux=new ProxyLinux(); | ||
| 19 | |||
| 20 | private ProxyDBImpl proxydb=new ProxyDBImpl(); | ||
| 21 | |||
| 22 | private Vector<String> vStr; | ||
| 23 | private Vector<ProxyBean> vPb; | ||
| 24 | |||
| 25 | public Vector<ProxyBean> getAllProxyBean() { | ||
| 26 | return proxydb.selectDb(); | ||
| 27 | |||
| 28 | } | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | public boolean Upd(Vector<ProxyBean> beans) { | ||
| 33 | |||
| 34 | return proxylinux.Config(beans); | ||
| 35 | |||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | |||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | function setModelToForm(proxy) { | ||
| 5 | |||
| 6 | var form=Ext.getCmp("formproxy"); | ||
| 7 | |||
| 8 | var fsProxy = form.down('#fs'+proxy.protocol); | ||
| 9 | |||
| 10 | if (proxy.enabled) { | ||
| 11 | |||
| 12 | fsProxy.checkboxCmp.setValue(true); | ||
| 13 | fsProxy.down('#'+proxy.protocol+'Adress').setValue(proxy.host); | ||
| 14 | fsProxy.down('#'+proxy.protocol+'Port').setValue(proxy.port); | ||
| 15 | |||
| 16 | var fsAuth = fsProxy.down('#fs'+proxy.protocol+'Auth'); | ||
| 17 | |||
| 18 | if (proxy.auth) { | ||
| 19 | fsAuth.checkboxCmp.setValue(true); | ||
| 20 | fsAuth.down('#'+proxy.protocol+'Login').setValue(proxy.login); | ||
| 21 | fsAuth.down('#'+proxy.protocol+'Password').setValue(proxy.pass); | ||
| 22 | |||
| 23 | }else { | ||
| 24 | fsAuth.checkboxCmp.setValue(false); | ||
| 25 | } | ||
| 26 | |||
| 27 | }else { | ||
| 28 | fsProxy.checkboxCmp.setValue(false); | ||
| 29 | } | ||
| 30 | |||
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | Ext.define('App.controller.Proxy', { | ||
| 35 | extend : 'Ext.app.Controller', | ||
| 36 | |||
| 37 | init : function() { | ||
| 38 | this.control({ | ||
| 39 | 'toolbar button[action=saveProxy]' : { | ||
| 40 | click : this.saveProxy | ||
| 41 | }, | ||
| 42 | |||
| 43 | 'toolbar button[action=loadProxy]': { | ||
| 44 | click : this.loadProxy | ||
| 45 | }, | ||
| 46 | |||
| 47 | 'mvvm-ProxyView': { | ||
| 48 | // selectionchange: this.gridSelectionChange, | ||
| 49 | // viewready: this.onViewReady, | ||
| 50 | // select: this.onRowSelect | ||
| 51 | } | ||
| 52 | }); | ||
| 53 | |||
| 54 | this.loadProxy(); | ||
| 55 | |||
| 56 | |||
| 57 | }, | ||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | saveProxy:function() { | ||
| 64 | |||
| 65 | var records = []; | ||
| 66 | |||
| 67 | records.push(this.getModelFromForm(0,"http")); | ||
| 68 | records.push(this.getModelFromForm(1,"https")); | ||
| 69 | records.push(this.getModelFromForm(2,"ftp")); | ||
| 70 | |||
| 71 | var data=Ext.util.JSON.encode(records); | ||
| 72 | |||
| 73 | Ext.Ajax.request({ | ||
| 74 | method: "POST", | ||
| 75 | url: 'api/proxy/update', | ||
| 76 | headers: { | ||
| 77 | 'Accept': 'application/json', | ||
| 78 | 'Content-Type': 'application/json' | ||
| 79 | }, | ||
| 80 | params: data, | ||
| 81 | success: function(response, opts) { | ||
| 82 | |||
| 83 | var Ok = Ext.JSON.decode(response.responseText); | ||
| 84 | if (Ok) { | ||
| 85 | Ext.Msg.alert('Success', 'Сохранение выполнено успешно'); | ||
| 86 | }else { | ||
| 87 | Ext.Msg.alert('Failure', 'Ошибка сохранения'); | ||
| 88 | } | ||
| 89 | |||
| 90 | }, failure: function(response, opts) { | ||
| 91 | |||
| 92 | Ext.Msg.alert('Failure', 'Ошибка сохранения'); | ||
| 93 | } | ||
| 94 | }); | ||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | |||
| 99 | }, | ||
| 100 | |||
| 101 | getModelFromForm:function (id,protocol) { | ||
| 102 | |||
| 103 | var host; | ||
| 104 | var port; | ||
| 105 | var login; | ||
| 106 | var pass; | ||
| 107 | var enabled; | ||
| 108 | var auth; | ||
| 109 | |||
| 110 | var proxy; | ||
| 111 | |||
| 112 | var formproxy=Ext.getCmp("formproxy"); | ||
| 113 | |||
| 114 | var fsHttps = formproxy.down('#fs'+protocol); | ||
| 115 | |||
| 116 | |||
| 117 | enabled=fsHttps.checkboxCmp.getValue(); | ||
| 118 | |||
| 119 | host=fsHttps.down('#'+protocol+'Adress').getValue(); | ||
| 120 | port=fsHttps.down('#'+protocol+'Port').getValue(); | ||
| 121 | |||
| 122 | var fsHttpsAuth=fsHttps.down('#fs'+protocol+'Auth'); | ||
| 123 | |||
| 124 | auth=fsHttpsAuth.checkboxCmp.getValue(); | ||
| 125 | |||
| 126 | login=fsHttpsAuth.down('#'+protocol+'Login').getValue(); | ||
| 127 | pass=fsHttpsAuth.down('#'+protocol+'Password').getValue(); | ||
| 128 | |||
| 129 | |||
| 130 | |||
| 131 | |||
| 132 | proxy = { | ||
| 133 | id:id, | ||
| 134 | protocol:protocol, | ||
| 135 | host:host, | ||
| 136 | port:parseInt(port), | ||
| 137 | login:login, | ||
| 138 | pass:pass, | ||
| 139 | enabled:enabled, | ||
| 140 | auth:auth | ||
| 141 | }; | ||
| 142 | |||
| 143 | return proxy; | ||
| 144 | }, | ||
| 145 | |||
| 146 | |||
| 147 | |||
| 148 | loadProxy:function() { | ||
| 149 | |||
| 150 | Ext.Ajax.request({ | ||
| 151 | method: "GET", | ||
| 152 | url: 'api/proxy/all', | ||
| 153 | headers: { | ||
| 154 | 'Accept': 'application/json', | ||
| 155 | 'Content-Type': 'application/json' | ||
| 156 | }, | ||
| 157 | |||
| 158 | success: function(response, opts) { | ||
| 159 | |||
| 160 | var result = Ext.JSON.decode(response.responseText); | ||
| 161 | |||
| 162 | for(var i in result){ | ||
| 163 | |||
| 164 | this.setModelToForm(result[i]); | ||
| 165 | } | ||
| 166 | |||
| 167 | |||
| 168 | }, failure: function(response, opts) { | ||
| 169 | } | ||
| 170 | }); | ||
| 171 | |||
| 172 | } | ||
| 173 | |||
| 174 | |||
| 175 | |||
| 176 | }); | ||
| 177 | |||
| 178 | |||
| 179 | |||
| 180 | |||
| 181 | |||
| 182 | |||
| 183 | |||
| 184 | |||
| 185 | |||
| 186 | |||
| 187 | |||
| 188 | |||
| 189 | |||
| 190 | |||
| 191 | |||
| 192 | |||
| 193 | |||
| 194 | |||
| 195 | |||
| 196 | |||
| 197 | |||
| 198 | |||
| 199 |
-
Please register or sign in to post a comment