add start page with chat explanation
This commit is contained in:
parent
a9df49329d
commit
2b3376a89b
|
@ -41,7 +41,7 @@ public class MainVerticle extends AbstractVerticle {
|
|||
|
||||
List<NetSocket> clients=new ArrayList<>();
|
||||
|
||||
// X509TrustManager tm=new MyTrustManager();
|
||||
// X509TrustManager tm=new MyTrustManager();
|
||||
|
||||
@Override
|
||||
public void start(Promise<Void> startPromise) throws Exception {
|
||||
|
@ -52,7 +52,7 @@ public class MainVerticle extends AbstractVerticle {
|
|||
// String certPath="c:/temp/cert.pem";
|
||||
String certPath="/home/lehmann/gemini-chat/cert.pem";
|
||||
|
||||
// TrustOptions trustOptions=new MyTrustOptions(vertx);
|
||||
// TrustOptions trustOptions=new MyTrustOptions(vertx);
|
||||
|
||||
TrustManagerFactory trustMgrFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
KeyStore keystore=KeyStore.getInstance("JKS");
|
||||
|
@ -67,20 +67,20 @@ public class MainVerticle extends AbstractVerticle {
|
|||
.setCertPath(certPath)
|
||||
.setKeyPath(certPath))
|
||||
.setSsl(true)
|
||||
// .setTrustOptions(trustOptions)
|
||||
// .setTrustOptions(trustOptions)
|
||||
.setTrustOptions(TrustOptions.wrap(trustManager))
|
||||
|
||||
// .setOpenSslEngineOptions(new OpenSSLEngineOptions())
|
||||
// .setOpenSslEngineOptions(new OpenSSLEngineOptions())
|
||||
.setClientAuth(ClientAuth.REQUEST)
|
||||
;
|
||||
|
||||
// SSLContext sc = SSLContext.getInstance("SSL");
|
||||
// sc.init(null, new X509TrustManager[] { tm }, null);
|
||||
// HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
// SSLContext sc = SSLContext.getInstance("SSL");
|
||||
// sc.init(null, new X509TrustManager[] { tm }, null);
|
||||
// HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
|
||||
vertx.createNetServer(options).connectHandler(conn -> {
|
||||
conn.handler(event -> {
|
||||
System.out.println(new Date().toString()+"accepted connection:"+conn.remoteAddress());
|
||||
System.out.println(new Date().toString()+" accepted connection:"+conn.remoteAddress());
|
||||
String url=event.toString("UTF-8");
|
||||
if(!url.endsWith("\r\n")) {
|
||||
conn.write("40 format error\r\n");
|
||||
|
@ -99,6 +99,23 @@ public class MainVerticle extends AbstractVerticle {
|
|||
conn.write("30 gemini://gemini.lehmann.cx:11965/\r\n");
|
||||
conn.close();
|
||||
}
|
||||
else if(path.equals("/")) {
|
||||
conn.write("20 text/gemini\r\n");
|
||||
conn.write("# a very simple chat server\n");
|
||||
conn.write("the chat page loads indefintely (until the connection breaks at least)\n");
|
||||
conn.write("and shows chat messages sent by other users\n");
|
||||
conn.write("messages can be sent via the /post url and use the client certificate to authenticate\n");
|
||||
conn.write("currently the sha256 hash of the client cert is used as user-id\n");
|
||||
conn.write("\n");
|
||||
conn.write("the source code for the server is at\n");
|
||||
conn.write("=> https://tildegit.org/alexlehm/vertx-gemini-server\n");
|
||||
conn.write("the author of this chat is reachable via\n");
|
||||
conn.write("=> gemini://gemini.lehmann.cx/\n");
|
||||
conn.write("\n");
|
||||
conn.write("click on the link to get started\n");
|
||||
conn.write("=> /chat\n");
|
||||
conn.close();
|
||||
}
|
||||
else if(path.startsWith("/post")) {
|
||||
System.out.println("post");
|
||||
try {
|
||||
|
@ -130,7 +147,7 @@ public class MainVerticle extends AbstractVerticle {
|
|||
}
|
||||
}
|
||||
} catch (SSLPeerUnverifiedException | CertificateEncodingException | NoSuchAlgorithmException ex) {
|
||||
// ex.printStackTrace();
|
||||
// ex.printStackTrace();
|
||||
conn.write("60 cert required\r\n");
|
||||
}
|
||||
conn.close();
|
||||
|
|
Loading…
Reference in New Issue