示例#1
0
static void
infd_server_pool_entry_publish_with(InfdServerPoolEntry* entry,
                                    InfdServerPoolPublisher* publisher)
{
  InfdTcpServer* tcp;
  guint port;

  switch(publisher->type)
  {
  case INFD_SERVER_POOL_PUBLISHER_LOCAL:
    g_assert(INFD_IS_XMPP_SERVER(entry->server));

    if(publisher->shared.local.item == NULL)
    {
      g_object_get(G_OBJECT(entry->server), "tcp-server", &tcp, NULL);
      g_object_get(G_OBJECT(tcp), "local-port", &port, NULL);
      g_object_unref(G_OBJECT(tcp));

      publisher->shared.local.item = inf_local_publisher_publish(
        publisher->shared.local.publisher,
        "_infinote._tcp",
        infd_server_pool_get_local_service_name(),
        port
      );
    }

    break;
  default:
    g_assert_not_reached();
    break;
  }
}
示例#2
0
/**
 * infd_xmpp_server_get_security_policy:
 * @server: A #InfdXmppServer.
 *
 * Returns the current security policy for newly accepted
 * #InfXmppConnection<!-- -->s.
 *
 * Returns: The current security policy.
 */
InfXmppConnectionSecurityPolicy
infd_xmpp_server_get_security_policy(InfdXmppServer* server)
{
  g_return_val_if_fail(
    INFD_IS_XMPP_SERVER(server),
    INF_XMPP_CONNECTION_SECURITY_BOTH_PREFER_TLS
  );

  return INFD_XMPP_SERVER_PRIVATE(server)->security_policy;
}
示例#3
0
/**
 * infd_xmpp_server_set_security_policy:
 * @server: A #InfdXmppServer.
 * @policy: The new security policy.
 *
 * Sets the security policy for newly accepted #InfXmppConnection<!-- -->s.
 * Does not already established connections.
 */
void
infd_xmpp_server_set_security_policy(InfdXmppServer* server,
                                     InfXmppConnectionSecurityPolicy policy)
{
  InfdXmppServerPrivate* priv;

  g_return_if_fail(INFD_IS_XMPP_SERVER(server));

  priv = INFD_XMPP_SERVER_PRIVATE(server);

  if(policy != priv->security_policy)
  {
    g_return_if_fail(
      policy == INF_XMPP_CONNECTION_SECURITY_ONLY_UNSECURED ||
      priv->tls_creds != NULL
    );

    priv->security_policy = policy;
    g_object_notify(G_OBJECT(server), "security-policy");
  }
}
示例#4
0
/* TODO: Make a InfdLocalServer interface to query the port? */
void
infd_server_pool_add_local_publisher(InfdServerPool* server_pool,
                                     InfdXmppServer* server,
                                     InfLocalPublisher* publisher)
{
  InfdServerPoolPrivate* priv;
  InfdServerPoolEntry* entry;
  InfdServerPoolPublisher* server_pool_publisher;
  InfdXmlServerStatus status;

  g_return_if_fail(INFD_IS_SERVER_POOL(server_pool));
  g_return_if_fail(INFD_IS_XMPP_SERVER(server));
  g_return_if_fail(INF_IS_LOCAL_PUBLISHER(publisher));

  priv = INFD_SERVER_POOL_PRIVATE(server_pool);
  entry = (InfdServerPoolEntry*)g_hash_table_lookup(priv->servers, server);
  g_return_if_fail(entry != NULL);

  /* TODO: Bail if we are already publishing via this publisher */

  /* TODO: Only announce on the address family server is listening on.
   * Otherwise we might announce the service on ipv6 without anyone
   * listening there. */
  server_pool_publisher = g_slice_new(InfdServerPoolPublisher);
  server_pool_publisher->type = INFD_SERVER_POOL_PUBLISHER_LOCAL;
  server_pool_publisher->shared.local.publisher = publisher;
  server_pool_publisher->shared.local.item = NULL;
  g_object_ref(G_OBJECT(publisher));

  entry->publishers = g_slist_prepend(
    entry->publishers,
    server_pool_publisher
  );

  /* Initial publish when server is open */
  g_object_get(G_OBJECT(server), "status", &status, NULL);
  if(status == INFD_XML_SERVER_OPEN)
    infd_server_pool_entry_publish_with(entry, server_pool_publisher);
}