milterを使った効果的な迷惑メール対策 - milter manager

MilterServerContext

MilterServerContext — サーバ側のmilterプロトコルを処理します。

Functions

GQuark milter_server_context_error_quark ()
MilterServerContext * milter_server_context_new ()
void milter_server_context_set_connection_timeout ()
void milter_server_context_set_writing_timeout ()
void milter_server_context_set_reading_timeout ()
void milter_server_context_set_end_of_message_timeout ()
void milter_server_context_set_all_timeouts ()
gboolean milter_server_context_set_connection_spec ()
gboolean milter_server_context_establish_connection ()
MilterStatus milter_server_context_get_status ()
void milter_server_context_set_status ()
MilterServerContextState milter_server_context_get_state ()
void milter_server_context_set_state ()
MilterServerContextState milter_server_context_get_last_state ()
gboolean milter_server_context_is_processing ()
gboolean milter_server_context_negotiate ()
gboolean milter_server_context_connect ()
gboolean milter_server_context_helo ()
gboolean milter_server_context_envelope_from ()
gboolean milter_server_context_envelope_recipient ()
gboolean milter_server_context_data ()
gboolean milter_server_context_unknown ()
gboolean milter_server_context_header ()
gboolean milter_server_context_end_of_header ()
gboolean milter_server_context_body ()
gboolean milter_server_context_end_of_message ()
gboolean milter_server_context_quit ()
gboolean milter_server_context_abort ()
void milter_server_context_set_option ()
MilterOption * milter_server_context_get_option ()
gboolean milter_server_context_is_enable_step ()
gboolean milter_server_context_get_skip_body ()
const gchar * milter_server_context_get_name ()
void milter_server_context_set_name ()
gdouble milter_server_context_get_elapsed ()
gboolean milter_server_context_is_negotiated ()
gboolean milter_server_context_is_processing_message ()
void milter_server_context_set_processing_message ()
gboolean milter_server_context_is_quitted ()
void milter_server_context_set_quitted ()
void milter_server_context_reset_message_related_data ()
MilterMessageResult * milter_server_context_get_message_result ()
void milter_server_context_set_message_result ()
gboolean milter_server_context_need_reply ()
gboolean milter_server_context_has_accepted_recipient ()

プロパティ

gdouble connection-timeout Read / Write / Construct
gdouble end-of-message-timeout Read / Write / Construct
MilterMessageResult * message-result Read / Write
gchar * name Read / Write
gdouble reading-timeout Read / Write / Construct
MilterServerContextState state Read / Write
MilterStatus status Read / Write
gdouble writing-timeout Read / Write / Construct

オブジェクト階層

    GEnum
    ├── MilterServerContextError
    ╰── MilterServerContextState
    GObject
    ╰── MilterAgent
        ╰── MilterProtocolAgent
            ╰── MilterServerContext
                ╰── MilterManagerChild

説明

MilterServerContextは1つのサーバ側のmilterプロトコルセッションを処理します。これは各milterプロトコルセッション毎にMilterServerContextインスタンスが生成されるということです。

Functions

milter_server_context_error_quark ()

GQuark
milter_server_context_error_quark (void);

milter_server_context_new ()

MilterServerContext *
milter_server_context_new (void);

新しいコンテキストオブジェクトを生成します。

Returns

新しいMilterServerContextオブジェクト。


milter_server_context_set_connection_timeout ()

void
milter_server_context_set_connection_timeout
                               (MilterServerContext *context,
                                gdouble timeout);

Sets the timeout in seconds on connection. If context doesn't connects to client in timeout seconds, “timeout” signal is emitted.

Parameters

context

MilterServerContext

 

timeout

the connection timeout in seconds. (default is MILTER_SERVER_CONTEXT_DEFAULT_CONNECTION_TIMEOUT)

 

milter_server_context_set_writing_timeout ()

void
milter_server_context_set_writing_timeout
                               (MilterServerContext *context,
                                gdouble timeout);

Sets the timeout in seconds on writing. If context doesn't write to client socket in timeout seconds, “timeout” signal is emitted.

Parameters

context

MilterServerContext

 

timeout

the writing timeout in seconds. (default is MILTER_SERVER_CONTEXT_DEFAULT_WRITING_TIMEOUT)

 

milter_server_context_set_reading_timeout ()

void
milter_server_context_set_reading_timeout
                               (MilterServerContext *context,
                                gdouble timeout);

Sets the timeout in seconds on reading. If context doesn't receive response from client socket in timeout seconds, “timeout” signal is emitted.

Parameters

context

MilterServerContext

 

timeout

the reading timeout in seconds. (default is MILTER_SERVER_CONTEXT_DEFAULT_READING_TIMEOUT)

 

milter_server_context_set_end_of_message_timeout ()

void
milter_server_context_set_end_of_message_timeout
                               (MilterServerContext *context,
                                gdouble timeout);

Sets the timeout in seconds on end-of-message. If context doesn't receive response for end-of-message from client socket in timeout seconds, “timeout” signal is emitted.

Parameters

context

MilterServerContext

 

timeout

the timeout in seconds on end-of-message. (default is MILTER_SERVER_CONTEXT_DEFAULT_END_OF_MESSAGE_TIMEOUT)

 

milter_server_context_set_all_timeouts ()

void
milter_server_context_set_all_timeouts
                               (MilterServerContext *context,
                                gdouble timeout);

Sets the timeout in seconds on connection, writing, reading and end-of-message at once.

See the comments of the fllowing functions about each timeout:

  1. milter_server_context_set_connection_timeout()

  2. milter_server_context_set_writing_timeout()

  3. milter_server_context_set_reading_timeout()

  4. milter_server_context_set_end_of_message_timeout()

Parameters

context

MilterServerContext

 

timeout

the timeout in seconds.

 

Since: 2.1.0


milter_server_context_set_connection_spec ()

gboolean
milter_server_context_set_connection_spec
                               (MilterServerContext *context,
                                const gchar *spec,
                                GError **error);

Sets a connection specification of client. If spec is invalid format and error is not NULL, error detail is stored into error .

Parameters

context

MilterServerContext

 

spec

クライアントの接続指定。

 

error

エラーを受け取る場所のアドレス、またはNULL

 

Returns

成功時はTRUE


milter_server_context_establish_connection ()

gboolean
milter_server_context_establish_connection
                               (MilterServerContext *context,
                                GError **error);

Establishes a connection to client. If establishing is failed and error is not NULL, error detail is stored into error .

Parameters

context

MilterServerContext

 

error

エラーを受け取る場所のアドレス、またはNULL

 

Returns

成功時はTRUE


milter_server_context_get_status ()

MilterStatus
milter_server_context_get_status (MilterServerContext *context);

現在の状態を取得します。

Parameters

context

MilterServerContext

 

Returns

現在の状態。


milter_server_context_set_status ()

void
milter_server_context_set_status (MilterServerContext *context,
                                  MilterStatus status);

Sets the current status.

Parameters

context

MilterServerContext

 

status

the new status.

 

milter_server_context_get_state ()

MilterServerContextState
milter_server_context_get_state (MilterServerContext *context);

現在の状態を取得します。

Parameters

context

MilterServerContext

 

Returns

現在の状態。


milter_server_context_set_state ()

void
milter_server_context_set_state (MilterServerContext *context,
                                 MilterServerContextState state);

現在の状態を設定します。

Parameters

context

MilterServerContext

 

state

新しい状態。

 

milter_server_context_get_last_state ()

MilterServerContextState
milter_server_context_get_last_state (MilterServerContext *context);

Gets the last state. It's one of start, negotiate, connect, helo, envelope-from, envelope-recipient, data, unknown, header, end-of-header, body and end-of-message.

Parameters

context

MilterServerContext

 

Returns

the last state.


milter_server_context_is_processing ()

gboolean
milter_server_context_is_processing (MilterServerContext *context);

応答を待っているかどうかを取得します。

Parameters

context

MilterServerContext

 

Returns

最後の書き込みの後に応答を受け取っていたらTRUE、そうでなければFALSE


milter_server_context_negotiate ()

gboolean
milter_server_context_negotiate (MilterServerContext *context,
                                 MilterOption *option);

クライアントとネゴシエーションします。

Parameters

context

MilterServerContext

 

option

ネゴシエーションのオプション。

 

Returns

成功時はTRUE


milter_server_context_connect ()

gboolean
milter_server_context_connect (MilterServerContext *context,
                               const gchar *host_name,
                               struct sockaddr *address,
                               socklen_t address_length);

接続されたSMTPクライアントの情報を送信します。

Parameters

context

MilterServerContext

 

host_name

接続してきたSMTPクライアントのホスト名。

 

address

接続してきたSMTPクライアントのアドレス。

 

address_length

the length of address .

 

Returns

成功時はTRUE


milter_server_context_helo ()

gboolean
milter_server_context_helo (MilterServerContext *context,
                            const gchar *fqdn);

HELOに渡されたFQDNを送信します。

Parameters

context

MilterServerContext

 

fqdn

FQDN。

 

Returns

成功時はTRUE


milter_server_context_envelope_from ()

gboolean
milter_server_context_envelope_from (MilterServerContext *context,
                                     const gchar *from);

MAIL FROM時に渡されたパラメタを送信します。

Parameters

context

MilterServerContext

 

from

送信者のアドレス。

 

Returns

成功時はTRUE


milter_server_context_envelope_recipient ()

gboolean
milter_server_context_envelope_recipient
                               (MilterServerContext *context,
                                const gchar *recipient);

RCPT TO時に渡されたパラメタを送信します。

Parameters

context

MilterServerContext

 

recipient

宛先アドレス。

 

Returns

成功時はTRUE


milter_server_context_data ()

gboolean
milter_server_context_data (MilterServerContext *context);

DATAコマンドを受信したことを通知します。

Parameters

context

MilterServerContext

 

Returns

成功時はTRUE


milter_server_context_unknown ()

gboolean
milter_server_context_unknown (MilterServerContext *context,
                               const gchar *command);

受信した未知のSMTPコマンドを送信します。

Parameters

context

MilterServerContext

 

command

未知のSMTPコマンド。

 

Returns

成功時はTRUE


milter_server_context_header ()

gboolean
milter_server_context_header (MilterServerContext *context,
                              const gchar *name,
                              const gchar *value);

ヘッダを送信します。

Parameters

context

MilterServerContext

 

name

ヘッダ名。

 

value

ヘッダ値。

 

Returns

成功時はTRUE


milter_server_context_end_of_header ()

gboolean
milter_server_context_end_of_header (MilterServerContext *context);

すべてのヘッダが送信されたことを通知します。

Parameters

context

MilterServerContext

 

Returns

成功時はTRUE


milter_server_context_body ()

gboolean
milter_server_context_body (MilterServerContext *context,
                            const gchar *chunk,
                            gsize size);

本文の1かたまりを送信します。

Parameters

context

MilterServerContext

 

chunk

本文の1かたまり。

 

size

the size of chunk .

 

Returns

成功時はTRUE


milter_server_context_end_of_message ()

gboolean
milter_server_context_end_of_message (MilterServerContext *context,
                                      const gchar *chunk,
                                      gsize size);

すべての本文のかたまりを送信したことを通知します。未送信の最後の本文のかたまりも一緒に送信することができます。

Parameters

context

MilterServerContext

 

chunk

本文のかたまり。NULLかもしれません。

 

size

the size of chunk .

 

Returns

成功時はTRUE


milter_server_context_quit ()

gboolean
milter_server_context_quit (MilterServerContext *context);

現在の接続を終了します。

Parameters

context

MilterServerContext

 

Returns

成功時はTRUE


milter_server_context_abort ()

gboolean
milter_server_context_abort (MilterServerContext *context);

現在の接続を中止します。

Parameters

context

MilterServerContext

 

Returns

成功時はTRUE


milter_server_context_set_option ()

void
milter_server_context_set_option (MilterServerContext *context,
                                  MilterOption *option);

Set negotiate option.

Parameters

context

MilterServerContext

 

option

ネゴシエーションのオプション。

 

milter_server_context_get_option ()

MilterOption *
milter_server_context_get_option (MilterServerContext *context);

Get negotiate option.

Parameters

context

MilterServerContext

 

milter_server_context_is_enable_step ()

gboolean
milter_server_context_is_enable_step (MilterServerContext *context,
                                      MilterStepFlags step);

Gets whether step flag is enabled in the context 's option.

Parameters

context

MilterServerContext

 

step

ステップフラグ。

 

Returns

stepフラグが有効ならTRUE、そうでなければFALSE


milter_server_context_get_skip_body ()

gboolean
milter_server_context_get_skip_body (MilterServerContext *context);

contextが本文のかたまりを送っている間にスキップ応答を受け取ったかどうかを取得します。

Parameters

context

MilterServerContext

 

Returns

本文のかたまりを省略していたらTRUE、そうでなければFALSE


milter_server_context_get_name ()

const gchar *
milter_server_context_get_name (MilterServerContext *context);

Gets the name of context .

Parameters

context

MilterServerContext

 

Returns

the name of context .


milter_server_context_set_name ()

void
milter_server_context_set_name (MilterServerContext *context,
                                const gchar *name);

Sets the name of context .

Parameters

context

MilterServerContext

 

name

名前。

 

milter_server_context_get_elapsed ()

gdouble
milter_server_context_get_elapsed (MilterServerContext *context);

Gets the elapsed time.

Parameters

context

MilterServerContext

 

Returns

the elapsed time of context .


milter_server_context_is_negotiated ()

gboolean
milter_server_context_is_negotiated (MilterServerContext *context);

Gets whether negotiation is succeeded.

Parameters

context

MilterServerContext

 

Returns

TRUE if context is negotiated, FALSE otherwise.


milter_server_context_is_processing_message ()

gboolean
milter_server_context_is_processing_message
                               (MilterServerContext *context);

Gets whether the context is processing message.

Parameters

context

MilterServerContext

 

Returns

TRUE if context is processing message, FALSE otherwise.


milter_server_context_set_processing_message ()

void
milter_server_context_set_processing_message
                               (MilterServerContext *context,
                                gboolean processing_message);

Sets whether the context is processing message.

Parameters

context

MilterServerContext

 

processing

whether the context is processing message.

 

milter_server_context_is_quitted ()

gboolean
milter_server_context_is_quitted (MilterServerContext *context);

Gets whether the context is quitted.

Parameters

context

MilterServerContext

 

Returns

TRUE if context is quitted, FALSE otherwise.


milter_server_context_set_quitted ()

void
milter_server_context_set_quitted (MilterServerContext *context,
                                   gboolean quitted);

Sets whether the context is quitted.

Parameters

context

MilterServerContext

 

quitted

whether the context is quitted.

 

milter_server_context_reset_message_related_data ()

void
milter_server_context_reset_message_related_data
                               (MilterServerContext *context);

Resets message related data in the context. It should be called before each 2nd or later messages in the same milter session. There are no bad effects if it is called before 1st message.

Parameters

context

MilterServerContext

 

milter_server_context_get_message_result ()

MilterMessageResult *
milter_server_context_get_message_result
                               (MilterServerContext *context);

Gets the message result of context .

Parameters

context

MilterServerContext

 

Returns

the message result of context .


milter_server_context_set_message_result ()

void
milter_server_context_set_message_result
                               (MilterServerContext *context,
                                MilterMessageResult *result);

Sets the message result of context .

Parameters

context

MilterServerContext

 

result

the message result.

 

milter_server_context_need_reply ()

gboolean
milter_server_context_need_reply (MilterServerContext *context,
                                  MilterServerContextState state);

Gets whether the context needs to reply on state .

Parameters

context

MilterServerContext

 

state

a MilterServerContextState.

 

Returns

TRUE if context needs to reply on state , FALSE otherwise.


milter_server_context_has_accepted_recipient ()

gboolean
milter_server_context_has_accepted_recipient
                               (MilterServerContext *context);

Returns TRUE if the context has one or more accepted recipients. If the context doesn't know about recipients, it always returns FALSE.

Parameters

context

MilterServerContext

 

Returns

TRUE if context has one or more accepted recipients, FALSE otherwise.

Types and Values

MILTER_SERVER_CONTEXT_ERROR

#define MILTER_SERVER_CONTEXT_ERROR           (milter_server_context_error_quark())

MilterServerContextのエラー用のGErrorクォークを取得するために使われます。


MILTER_SERVER_CONTEXT_DEFAULT_CONNECTION_TIMEOUT

#define MILTER_SERVER_CONTEXT_DEFAULT_CONNECTION_TIMEOUT     300

The default connection timeout in seconds.


MILTER_SERVER_CONTEXT_DEFAULT_WRITING_TIMEOUT

#define MILTER_SERVER_CONTEXT_DEFAULT_WRITING_TIMEOUT         10

The default writing timeout in seconds.


MILTER_SERVER_CONTEXT_DEFAULT_READING_TIMEOUT

#define MILTER_SERVER_CONTEXT_DEFAULT_READING_TIMEOUT         10

The default reading timeout in seconds.


MILTER_SERVER_CONTEXT_DEFAULT_END_OF_MESSAGE_TIMEOUT

#define MILTER_SERVER_CONTEXT_DEFAULT_END_OF_MESSAGE_TIMEOUT 300

The default end-of-message response timeout in seconds.


enum MilterServerContextError

MilterServerContextの関数呼び出し中に発生するエラーを識別します。

Members

MILTER_SERVER_CONTEXT_ERROR_CONNECTION_FAILURE

接続が失敗したことを示します。

 

MILTER_SERVER_CONTEXT_ERROR_NO_SPEC

接続指定が設定されていないことを示します。

 

MILTER_SERVER_CONTEXT_ERROR_INVALID_STATE

現在のMilterServerContextが予期しない応答を受け取ったことを示します。

 

MILTER_SERVER_CONTEXT_ERROR_BUSY

前の操作の結果を受け取る前に新しい操作が要求されたことを示します。

 

MILTER_SERVER_CONTEXT_ERROR_IO_ERROR

milterプロトコルデータの読み書き時に発生した入出力エラーを示します。

 

MILTER_SERVER_CONTEXT_ERROR_NEWER_VERSION_REQUESTED

未サポートの新しいバージョンが要求されたことを示します。

 

enum MilterServerContextState

MilterServerContextの状態を識別します。

Members

MILTER_SERVER_CONTEXT_STATE_INVALID

不正な状態。

 

MILTER_SERVER_CONTEXT_STATE_START

はじまったばかり。

 

MILTER_SERVER_CONTEXT_STATE_DEFINE_MACRO

マクロ定義を送信しました。

 

MILTER_SERVER_CONTEXT_STATE_NEGOTIATE

ネゴシエーション中。

 

MILTER_SERVER_CONTEXT_STATE_CONNECT

接続情報を送信しました。

 

MILTER_SERVER_CONTEXT_STATE_HELO

HELOコマンドの情報を送信しました。

 

MILTER_SERVER_CONTEXT_STATE_ENVELOPE_FROM

MAIL FROMコマンドの情報を送信しました。

 

MILTER_SERVER_CONTEXT_STATE_ENVELOPE_RECIPIENT

RCPT TOコマンドの情報を送信しました。

 

MILTER_SERVER_CONTEXT_STATE_DATA

DATAコマンドの情報を送信しました。

 

MILTER_SERVER_CONTEXT_STATE_UNKNOWN

未知のSMTPコマンドを送信しました。

 

MILTER_SERVER_CONTEXT_STATE_HEADER

ヘッダを送信した。

 

MILTER_SERVER_CONTEXT_STATE_END_OF_HEADER

すべてのヘッダを送信しました。

 

MILTER_SERVER_CONTEXT_STATE_BODY

本文の1かたまりを送信しました。

 

MILTER_SERVER_CONTEXT_STATE_END_OF_MESSAGE

本文すべてを送信しました。

 

MILTER_SERVER_CONTEXT_STATE_QUIT

終了要求を送信しました。

 

MILTER_SERVER_CONTEXT_STATE_ABORT

中止要求を送信しました。

 

プロパティ詳細

The “connection-timeout” property

  “connection-timeout”       gdouble

The timeout seconds for connecting to a filter.

Flags: Read / Write / Construct

Allowed values: >= 0

Default value: 300


The “end-of-message-timeout” property

  “end-of-message-timeout”   gdouble

The timeout seconds between sending end-of-message to a filter and waiting for its reply.

Flags: Read / Write / Construct

Allowed values: >= 0

Default value: 300


The “message-result” property

  “message-result”           MilterMessageResult *

現在処理中のメッセージの結果。

Flags: Read / Write


The “name” property

  “name”                     gchar *

MilterServerContextの名前。

Flags: Read / Write

デフォルト値: NULL


The “reading-timeout” property

  “reading-timeout”          gdouble

The timeout seconds for reading reply from a filter.

Flags: Read / Write / Construct

Allowed values: >= 0

デフォルト値: 10


The “state” property

  “state”                    MilterServerContextState

MilterServerContextの状態。

Flags: Read / Write

Default value: MILTER_SERVER_CONTEXT_STATE_START


The “status” property

  “status”                   MilterStatus

MilterServerContextのステータス。

Flags: Read / Write

Default value: MILTER_STATUS_NOT_CHANGE


The “writing-timeout” property

  “writing-timeout”          gdouble

The timeout seconds for writing information from MTA to a filter.

Flags: Read / Write / Construct

Allowed values: >= 0

デフォルト値: 10

シグナル詳細

The “connection-timeout” signal

void
user_function (MilterServerContext *milterservercontext,
               gpointer             user_data)

Flags: Run Last


The “end-of-message-timeout” signal

void
user_function (MilterServerContext *milterservercontext,
               gpointer             user_data)

Flags: Run Last


The “message-processed” signal

void
user_function (MilterServerContext *milterservercontext,
               MilterMessageResult *arg1,
               gpointer             user_data)

Flags: Run Last


The “reading-timeout” signal

void
user_function (MilterServerContext *milterservercontext,
               gpointer             user_data)

Flags: Run Last


The “ready” signal

void
user_function (MilterServerContext *milterservercontext,
               gpointer             user_data)

Flags: Run Last


The “state-transited” signal

void
user_function (MilterServerContext     *milterservercontext,
               MilterServerContextState arg1,
               gpointer                 user_data)

Flags: Run Last


The “stop-on-body” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gchar               *arg1,
               guint64              arg2,
               gpointer             user_data)

Flags: Run Last


The “stop-on-connect” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gchar               *arg1,
               gpointer             arg2,
               guint                arg3,
               gpointer             user_data)

Flags: Run Last


The “stop-on-data” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gpointer             user_data)

Flags: Run Last


The “stop-on-end-of-header” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gpointer             user_data)

Flags: Run Last


The “stop-on-end-of-message” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gchar               *arg1,
               guint64              arg2,
               gpointer             user_data)

Flags: Run Last


The “stop-on-envelope-from” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gchar               *arg1,
               gpointer             user_data)

Flags: Run Last


The “stop-on-envelope-recipient” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gchar               *arg1,
               gpointer             user_data)

Flags: Run Last


The “stop-on-header” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gchar               *arg1,
               gchar               *arg2,
               gpointer             user_data)

Flags: Run Last


The “stop-on-helo” signal

gboolean
user_function (MilterServerContext *milterservercontext,
               gchar               *arg1,
               gpointer             user_data)

Flags: Run Last


The “stopped” signal

void
user_function (MilterServerContext *milterservercontext,
               gpointer             user_data)

Flags: Run Last


The “writing-timeout” signal

void
user_function (MilterServerContext *milterservercontext,
               gpointer             user_data)

Flags: Run Last