# ./vncserver -help -rfbport port TCP port for RFB protocol -rfbportv6 port TCP6 port for RFB protocol -rfbwait time max time in ms to wait for RFB client -rfbauth passwd-file use authentication on RFB protocol (use 'storepasswd' to create a password file) -rfbversion 3.x Set the version of the RFB we choose to advertise -permitfiletransfer permit file transfer support -passwd plain-password use authentication (use plain-password as password, USE AT YOUR RISK) -deferupdate time time in ms to defer updates (default 40) -deferptrupdate time time in ms to defer pointer updates (default none) -desktop name VNC desktop name (default "LibVNCServer") -alwaysshared always treat new clients as shared -nevershared never treat new clients as shared -dontdisconnect don't disconnect existing clients when a new non-shared connection comes in (refuse new connection instead) -sslkeyfile path set path to private key file for encrypted WebSockets connections -sslcertfile path set path to certificate file for encrypted WebSockets connections -httpdir dir-path enable http server using dir-path home -httpport portnum use portnum for http connection -httpportv6 portnum use portnum for IPv6 http connection -enablehttpproxy enable http proxy support -progressive height enable progressive updating for slow links -listen ipaddr listen for connections only on network interface with addr ipaddr. '-listen localhost' and hostname work too. -listenv6 ipv6addr listen for IPv6 connections only on network interface with addr ipv6addr. '-listen localhost' and hostname work too.
http 자체는 disable 하는게 없다.
줄 9: 00084 if (strcmp(argv[i], "-help") == 0) { 줄 12: 00087 } else if (strcmp(argv[i], "-rfbport") == 0) { /* -rfbport port */ 줄 19: 00094 } else if (strcmp(argv[i], "-rfbportv6") == 0) { /* -rfbportv6 port */ 줄 26: 00101 } else if (strcmp(argv[i], "-rfbwait") == 0) { /* -rfbwait ms */ 줄 32: 00107 } else if (strcmp(argv[i], "-rfbauth") == 0) { /* -rfbauth passwd-file */ 줄 39: 00114 } else if (strcmp(argv[i], "-permitfiletransfer") == 0) { /* -permitfiletransfer */ 줄 41: 00116 } else if (strcmp(argv[i], "-rfbversion") == 0) { /* -rfbversion 3.6 */ 줄 47: 00122 } else if (strcmp(argv[i], "-passwd") == 0) { /* -passwd password */ 줄 57: 00132 } else if (strcmp(argv[i], "-deferupdate") == 0) { /* -deferupdate milliseconds */ 줄 63: 00138 } else if (strcmp(argv[i], "-deferptrupdate") == 0) { /* -deferptrupdate milliseconds */ 줄 69: 00144 } else if (strcmp(argv[i], "-desktop") == 0) { /* -desktop desktop-name */ 줄 75: 00150 } else if (strcmp(argv[i], "-alwaysshared") == 0) { 줄 77: 00152 } else if (strcmp(argv[i], "-nevershared") == 0) { 줄 79: 00154 } else if (strcmp(argv[i], "-dontdisconnect") == 0) { 줄 81: 00156 } else if (strcmp(argv[i], "-httpdir") == 0) { /* -httpdir directory-path */ 줄 87: 00162 } else if (strcmp(argv[i], "-httpport") == 0) { /* -httpport portnum */ 줄 94: 00169 } else if (strcmp(argv[i], "-httpportv6") == 0) { /* -httpportv6 portnum */ 줄 101: 00176 } else if (strcmp(argv[i], "-enablehttpproxy") == 0) { 줄 103: 00178 } else if (strcmp(argv[i], "-progressive") == 0) { /* -httpport portnum */ 줄 109: 00184 } else if (strcmp(argv[i], "-listen") == 0) { /* -listen ipaddr */ 줄 118: 00193 } else if (strcmp(argv[i], "-listenv6") == 0) { /* -listenv6 ipv6addr */ 줄 126: 00201 } else if (strcmp(argv[i], "-sslkeyfile") == 0) { /* -sslkeyfile sslkeyfile */ 줄 132: 00207 } else if (strcmp(argv[i], "-sslcertfile") == 0) { /* -sslcertfile sslcertfile */
static void dokey(rfbBool down,rfbKeySym key,rfbClientPtr cl) { if(down) { if(key==XK_Escape) rfbCloseClient(cl); else if(key==XK_F12) /* close down server, disconnecting clients */ rfbShutdownServer(cl->screen,TRUE); else if(key==XK_F11) /* close down server, but wait for all clients to disconnect */ rfbShutdownServer(cl->screen,FALSE);
rfbCheckPasswordByList()는 계정-패스워드 쌍으로 되어있는 값을 이용하여 로그인을 구현하는 기본 함수이다.
희망(?)을 가졌던 newClientHook 이벤트는 시도때도 없이 발생했고(원래 기대했던 것은 로그인 시 1회)
로그인 별로 어떤 계정이 로그인 성공,실패 했는지는 함수를 확장해서 만들어야 할 듯..
newClientHook 에서도 cl->viewOnly가 설정되지 않는 걸 보면, vnc client 측의 설정과는 별개 인 듯
/* for this method, authPasswdData is really a pointer to an array of char*'s, where the last pointer is 0. */ rfbBool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len) { char **passwds; int i=0;
24/03/2021 11:09:19 Pixel format for client 192.168.0.6: 24/03/2021 11:09:19 87 bpp, depth 5, little endian 24/03/2021 11:09:19 true colour: max r 47360 g 20997 b 2, shift r 179 g 0 b 77 24/03/2021 11:09:19 rfbSetTranslateFunction: client bits per pixel not 8, 16 or 32 24/03/2021 11:09:19 Client 192.168.0.6 gone
/* This call creates a mask and then a cursor: */ /* rfbScreen->defaultCursor = rfbMakeXCursor(exampleCursorWidth,exampleCursorHeight,exampleCursor,0); */
MakeRichCursor(rfbScreen);
/* initialize the server */ rfbInitServer(rfbScreen);
#ifndef BACKGROUND_LOOP_TEST #ifdef USE_OWN_LOOP { int i; for(i=0;rfbIsActive(rfbScreen);i++) { fprintf(stderr,"%d\r",i); rfbProcessEvents(rfbScreen,100000); } } #else /* this is the blocking event loop, i.e. it never returns */ /* 40000 are the microseconds to wait on select(), i.e. 0.04 seconds */ rfbRunEventLoop(rfbScreen,40000,FALSE); #endif /* OWN LOOP */ #else #if !defined(LIBVNCSERVER_HAVE_LIBPTHREAD) && !defined(LIBVNCSERVER_HAVE_WIN32THREADS) #error "I need pthreads or win32 threads for that." #endif /* catch Ctrl-C to set a flag for the main thread */ signal(SIGINT, intHandler); /* this is the non-blocking event loop; a background thread is started */ rfbRunEventLoop(rfbScreen,-1,TRUE); fprintf(stderr, "Running background loop...\n"); /* now we could do some cool things like rendering in idle time */ while (maintain_connection) { sleep(5); /* render(); */ } fprintf(stderr, "\nShutting down...\n"); rfbShutdownServer(rfbScreen, TRUE); #endif /* BACKGROUND_LOOP */
revind / revind.so / run / websockify 는 websockify 에서 나온거
libvncserver 와 noVNC와 websockify 의 조합으로 어찌 되긴 하는데..
~/libvncserver/webclients $ ls -al total 64 drwxr-xr-x 4 pi pi 4096 Aug 12 11:44 . drwxr-xr-x 16 pi pi 4096 Aug 12 11:03 .. -rwxr-xr-x 1 pi pi 25372 Aug 12 11:02 example -rw-r--r-- 1 pi pi 1601 Aug 12 10:32 index.vnc drwxr-xr-x 10 pi pi 4096 Aug 12 11:00 novnc -rwxr-xr-x 1 pi pi 424 Aug 12 11:39 rebind -rwxr-xr-x 1 pi pi 7508 Aug 12 11:39 rebind.so -rwxr-xr-x 1 pi pi 78 Aug 12 11:39 run drwxr-xr-x 3 pi pi 4096 Aug 12 11:28 websockify
인자는 아래와 같이 하고 실행!
$ ./run 5900 -- ./example
웹 브라우저에서 http://ip:5800 으로 접속하면 아래와 같이 뜨고
별다른 설정을 하지 않았다면 wss(websocket secure)를 안될테니 위에 "Click here to connect using noVNC"를 누른다.
약간의 시간을 기다리면(libvncserver의 웹 서버가 느린지 파일 전송이 좀 느리다)
아래와 같이 쨘~
+
한번 되더니 websockify 없이도 되네.. 머지?
+
runInBackground 의 값을 TRUE 로 해주면 웹 서버가 작동을 안한다 -_-
어떻게 해야 할까..
void rfbRunEventLoop ( rfbScreenInfoPtr screenInfo, long usec, rfbBool runInBackground )
static THREAD_ROUTINE_RETURN_TYPE listenerRun(void *data) { rfbScreenInfoPtr screen=(rfbScreenInfoPtr)data; int client_fd; struct sockaddr_storage peer; rfbClientPtr cl = NULL; socklen_t len; fd_set listen_fds; /* temp file descriptor list for select() */
/* Only checking socket state here and not using rfbIsActive() because: When rfbShutdownServer() is called by the client, it runs in the client-to-server thread's context, resulting in itself calling its own the pthread_join(), returning immediately, leaving the client-to-server thread to actually terminate _after_ the listener thread is terminated, leaving the client list still populated. */ /* TODO: HTTP is not handled */ }
/*----------------------------------------------------------------------------- * KeyEvent - key press or release * * Keys are specified using the "keysym" values defined by the X Window System. * For most ordinary keys, the keysym is the same as the corresponding ASCII * value. Other common keys are: * * BackSpace 0xff08 * Tab 0xff09 * Return or Enter 0xff0d * Escape 0xff1b * Insert 0xff63 * Delete 0xffff * Home 0xff50 * End 0xff57 * Page Up 0xff55 * Page Down 0xff56 * Left 0xff51 * Up 0xff52 * Right 0xff53 * Down 0xff54 * F1 0xffbe * F2 0xffbf * ... ... * F12 0xffc9 * Shift 0xffe1 * Control 0xffe3 * Meta 0xffe7 * Alt 0xffe9 */
typedef struct { uint8_t type; /* always rfbKeyEvent */ uint8_t down; /* true if down (press), false if up */ uint16_t pad; uint32_t key; /* key is specified as an X keysym */ } rfbKeyEventMsg;
#define sz_rfbKeyEventMsg 8
typedef struct { uint8_t type; /* always rfbQemuEvent */ uint8_t subtype; /* always 0 */ uint16_t down; uint32_t keysym; /* keysym is specified as an X keysym, may be 0 */ uint32_t keycode; /* keycode is specified as XT key code */ } rfbQemuExtendedKeyEventMsg;
#define sz_rfbQemuExtendedKeyEventMsg 12
내용이 부실한데 드래그를 구현하려면 down 이벤트를 보고 해당 버튼의 마스크가 사라질때 까지 보고 있어야 할 듯?
I had the same problem using VNC from my Chromebook and after updating to Ubuntu 14.04 LTS. I used the suggestion of the dconf-editor -> org.gnome.desktop.remote-access then "require-encryption = NO"