Mercurial Hosting > luan
comparison src/luan/modules/Rpc.luan @ 1206:6dfaf4e9ce71
use many anonymous cipher_suites
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 06 Mar 2018 20:23:50 -0700 |
parents | 8f14426f8ada |
children | 5b9856045e51 |
comparison
equal
deleted
inserted
replaced
1205:8f14426f8ada | 1206:6dfaf4e9ce71 |
---|---|
29 | 29 |
30 local Rpc = {} | 30 local Rpc = {} |
31 | 31 |
32 Rpc.port = 9101 | 32 Rpc.port = 9101 |
33 | 33 |
34 Rpc.cipher_suite = "SSL_DH_anon_WITH_DES_CBC_SHA" | 34 Rpc.cipher_suites = { |
35 "TLS_DH_anon_WITH_AES_128_GCM_SHA256" | |
36 "TLS_DH_anon_WITH_AES_128_CBC_SHA256" | |
37 "TLS_ECDH_anon_WITH_AES_128_CBC_SHA" | |
38 "TLS_DH_anon_WITH_AES_128_CBC_SHA" | |
39 "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA" | |
40 "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA" | |
41 "TLS_ECDH_anon_WITH_RC4_128_SHA" | |
42 "SSL_DH_anon_WITH_RC4_128_MD5" | |
43 "SSL_DH_anon_WITH_DES_CBC_SHA" | |
44 "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA" | |
45 "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5" | |
46 } | |
35 | 47 |
36 local function java_args(list) | 48 local function java_args(list) |
37 for i,v in ipairs(list) do | 49 for i,v in ipairs(list) do |
38 list[i] = JavaLuan.toJava(v) | 50 list[i] = JavaLuan.toJava(v) |
39 end | 51 end |
159 return responder | 171 return responder |
160 end_function | 172 end_function |
161 | 173 |
162 function Rpc.remote(domain) | 174 function Rpc.remote(domain) |
163 local socket | 175 local socket |
164 if Rpc.cipher_suite == nil then | 176 if Rpc.cipher_suites == nil then |
165 socket = Socket.new(domain,Rpc.port) | 177 socket = Socket.new(domain,Rpc.port) |
166 else | 178 else |
167 socket = SSLSocketFactory.getDefault().createSocket(domain,Rpc.port) | 179 socket = SSLSocketFactory.getDefault().createSocket(domain,Rpc.port) |
168 socket.setEnabledCipherSuites{Rpc.cipher_suite} | 180 socket.setEnabledCipherSuites(Rpc.cipher_suites) |
169 end | 181 end |
170 local call = rpc_caller(socket) | 182 local call = rpc_caller(socket) |
171 local mt = {} | 183 local mt = {} |
172 function mt.__index(_,key) | 184 function mt.__index(_,key) |
173 return function(...) | 185 return function(...) |
181 | 193 |
182 function Rpc.serve(port,fns) | 194 function Rpc.serve(port,fns) |
183 port = port or Rpc.port | 195 port = port or Rpc.port |
184 fns = fns or Rpc.functions | 196 fns = fns or Rpc.functions |
185 local socket_server | 197 local socket_server |
186 if Rpc.cipher_suite == nil then | 198 if Rpc.cipher_suites == nil then |
187 socket_server = ServerSocket.new(port) | 199 socket_server = ServerSocket.new(port) |
188 else | 200 else |
189 socket_server = SSLServerSocketFactory.getDefault().createServerSocket(port) | 201 socket_server = SSLServerSocketFactory.getDefault().createServerSocket(port) |
190 socket_server.setEnabledCipherSuites{Rpc.cipher_suite} | 202 socket_server.setEnabledCipherSuites(Rpc.cipher_suites) |
191 end | 203 end |
192 while true do | 204 while true do |
193 try { | 205 try { |
194 function() | 206 function() |
195 local socket = socket_server.accept() | 207 local socket = socket_server.accept() |