예제 #1
0
int main(int argc, const char** argv) {
    pagekite_mgr pkm;

    if (argc < 3) {
        fprintf(stderr, "Usage: hello yourkite.pagekite.me password\n");
        return 1;
    }

    pkm = pagekite_init_pagekitenet(
        "ssh kite server",   /* What app is this?                       */
        1,                   /* Max number of kites we plan to fly      */
        25,                  /* Max number of simultaneous client conns */
        PK_WITH_DEFAULTS,    /* Use defaults (SSL, IPv4 and IPv6)       */
        PK_LOG_NORMAL);      /* Log verbosity level                     */

    if (pkm == NULL) {
        pagekite_perror(pkm, argv[0]);
        return 2;
    }

    /* Add a kite for the ssh server on localhost:22 */
    if (0 > pagekite_add_kite(pkm,
                              "raw",           /* Kite protocol         */
                              argv[1],         /* Kite name             */
                              22,              /* Public port, 0=any    */
                              argv[2],         /* Kite secret           */
                              "localhost",     /* Origin server host    */
                              22))             /* Origin server port    */
    {
        pagekite_perror(pkm, argv[0]);
        return 3;
    }

    /* Start the worker thread, wait for it to exit. */
    assert(-1 < pagekite_thread_start(pkm));
    assert(-1 < pagekite_thread_wait(pkm));

    /* Not reached: Nothing actually shuts us down in this app. */
    assert(-1 < pagekite_free(pkm));

    return 0;
}
예제 #2
0
jboolean Java_net_pagekite_lib_PageKiteAPI_initPagekitenet(
  JNIEnv* env, jclass unused_class
, jstring japp_id
, jint jmax_kites
, jint jmax_conns
, jint jflags
, jint jverbosity
){
  if (pagekite_manager_global != NULL) return JNI_FALSE;

  const jbyte* app_id = NULL;
  if (japp_id != NULL) app_id = (*env)->GetStringUTFChars(env, japp_id, NULL);
  int max_kites = jmax_kites;
  int max_conns = jmax_conns;
  int flags = jflags;
  int verbosity = jverbosity;

  pagekite_manager_global = pagekite_init_pagekitenet(app_id, max_kites, max_conns, flags, verbosity);

  if (japp_id != NULL) (*env)->ReleaseStringUTFChars(env, japp_id, app_id);
  return (pagekite_manager_global != NULL);
}