Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolat committed Apr 6, 2024
0 parents commit 7c87c72
Show file tree
Hide file tree
Showing 14 changed files with 621 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
lib
profile
node.exe
node-LICENSE
package-lock.json
121 changes: 121 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Creative Commons Legal Code

CC0 1.0 Universal

CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.

Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").

Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.

For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:

i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.

4. Limitations and Disclaimers.

a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
160 changes: 160 additions & 0 deletions SHIOLINK-readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
===============================================================
SHIOLINK.DLL:栞プロキシDLL
===============================================================

■SHIOLINKとは?
匿名PIPE通信を利用した子プロセスとの通信プロキシSHIORIです。起
動時に指定されたexeファイルを別プロセスで起動し、本体から送られ
るSHIORI REQUESTを起動したexeの標準入出力へのやり取りに変換し、
その結果を本体に返します。


■ライセンス
本ソフトウェアのghost部分に関しては、修正BSDライセンスとします。
現在のshellについては、フリーシェル配布者のライセンスに従ってく
ださい。

・修正BSDライセンス日本語訳
http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license


■著作(敬称略)
dll および ghost : どっとステーション
shell : 白兎一哉(フリーシェル「自由なみかず」)
使用ライブラリ等については「ビルドについて」を参照。


■配布ファイル
サンプルゴースト(動作には.Net Framework 2.0が必要です)


■ディレクトリ構成
[GHOST-DIR]
├─[ghost]
│   [master]
│    ├─descript.txt :SHIORI設定記述ファイル
│    ├─SHIOLINK.dll :プロキシSHIORI DLL
│    ├─SHIOLINK.ini :プロキシSHIORIのINIファイル
│    │         (DLL名の拡張子を.iniにしたもの)
│    └─LINKSHIO.exe :プロキシ栞が呼び出すexe
│              (サンプル。要.Net Framework 2.0)
└─[shell]
   ...


■設定ファイルの記述
SHIOLINK.ini
*--------------------------------------------------------------
[SHIOLINK]
; コマンドライン:
commandline = cscript /Nologo LINKJS.js

; 文字モード: ANSI(Shift_JIS) / UTF-8 の何れか
charmode = ANSI

[LOGGING]
; ログファイル名:
file = SHIOLINK.log

; ログレベル: debug / info / warn / error / fatal / none
level = debug
*--------------------------------------------------------------


■起動されるexeの環境
SHIOLINK.dllは指定されたexeなどを起動しますが、起動に先立ち次
の設定を行います。

* カレントディレクトリを[/ghost/master]ディレクトリに
* exeのSTDIN/STDOUTに、SHIOLINK.dllの匿名パイプをつなぐ

つまり、exe側は、[/ghost/master]ディレクトリで起動されたと仮定
し、標準入出力を相手にコマンド処理を随時行えばいいことになりま
す。実装試験などの場合は標準入力に対し適当にテキストを投入して
やることで、試験を行うことができます。

# >> LINKSHIO.exe < request.txt > response.txt
# *これで、response.txtに結果が返る


■通信プロトコル
本システムの文字エンコードはUTF-8/ANSI(SHIFT-JIS)の選択です。

SHIORI REQUESTに、同期処理用のコマンドを若干追加しています。

例) --> 栞プロキシのrequest
<-- exe側のresponse
*--------------------------------------------------------------
1 | --> *L:C:\[省略]\ghost\SHIOLINK\ghost\master
| <-- [応答なし]
|
*--------------------------------------------------------------
2 | --> *S:F6BA264E-AEA9-4886-B291-01C4664C504D
|
*--------------------------------------------------------------
3 | --> *S:F6BA264E-AEA9-4886-B291-01C4664C504D
|
*--------------------------------------------------------------
4 | --> GET SHIORI/3.0
| Sender: SSP
| Charset: UTF-8
| SecurityLevel: local
| ID: OnBoot
| Reference0: しおLINK!
| [空行]
|
*--------------------------------------------------------------
5 | <-- SHIORI/3.0 200 OK
| Charset: UTF-8
| Sender: LINKSHIO
| Value: \u\s[10]\h\s[0]さて、[~省略~]\-
| [空行]
|
*--------------------------------------------------------------
6 | --> *U:
| <-- [応答なし、終了]
*--------------------------------------------------------------


■流れ
すべてのやり取りは改行で区切られます。*で始まる行が同期コマン
ドです。*で始まる、exe側が知らないコマンドが流れてきた場合はす
べて読み捨ててください。

1. [*L:]コマンドは[SHIORI::load]命令に相当します。起動時に
[*L:(loaddir)]と送られます。このコマンドに対する応答はあ
りません。

2. [*S:]コマンドは[SHIORI::request]命令の同期のために発行さ
れます。[*S:(GUID)]となっています。

3. exe側は、来た[*S:]コマンドの内容をそのままオウム返しして
ください。SHIOLINK.DLLはこの応答を待って[SHIORI::request]
本体を送信します。

4. [SHIORI::request]本体です。空行までがリクエストです。
exe側は空行が来るまでテキストを読み込んでください。

5. [SHIORI::request]に対するレスポンスです。空行までがレスポ
ンス扱いとなります。

6. [*U:]コマンドは[SHIORI::unload]命令に相当します。exe側は終
了処理を行い、直ちに終了してください。このコマンドに対する
応答はありません。


■ビルドについて
SHIOLINK.DLLでは、以下のライブラリを利用しています。

・POCO C++ Libraries
http://www.pocoproject.org/

・INIMONI C++用iniファイル読み書きテンプレート作成ソフト
http://www18.ocn.ne.jp/~amedas/inimoni/

・RLOG()
http://hogeinstein.blog93.fc2.com/blog-entry-109.html


POCOに関してはincludeパス、libパスに含まれている必要があります。

Binary file added SHIOLINK.dll
Binary file not shown.
9 changes: 9 additions & 0 deletions SHIOLINK.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[SHIOLINK]
commandline = node.exe ./node_modules/shiolinkjs/dist/bin/shiolinkjs.js ./lib/shiori.js
charmode = UTF-8

[LOGGING]
file = SHIOLINK.log

; debug / info / warn / error / fatal / none
level = debug
10 changes: 10 additions & 0 deletions descript.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
charset,UTF-8
type,plugin
name,Nostrゅう
id,a80c8840-f39e-11ee-96b0-0800200c9a66
filename,SHIOLINK.dll
craftman,Don
craftmanurl,
homeurl,
secondchangeinterval,0
readme.charset,UTF-8
4 changes: 4 additions & 0 deletions install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
charset,UTF-8
type,plugin
name,Nostrゅう
directory,nostryu
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"private": true,
"scripts": {
"clean:ts": "shx rm -rf lib",
"build": "npm-run-all clean:ts build:ts",
"build:ts": "tsc",
"watch": "npm-run-all clean:ts watch:ts",
"watch:ts": "tsc -w",
"nar": "npm-run-all updates nar:make",
"nar:make": "mknar ../../ ../../ghost.nar sjis",
"updates": "npm-run-all exclude-dev updates:make",
"updates:make": "mkupdates ../../",
"exclude-dev": "node tools/excludeDevelopmentPackages.js",
"lint": "tslint -p . -t verbose"
},
"dependencies": {
"nostr-tools": "2.2.0",
"shiolinkjs": "^3.1.2",
"shiorijk": "^1.1.5",
"ws": "^8.16.0"
},
"devDependencies": {
"@types/node": "^20.12.5",
"narmaker": "^1.3.0",
"normalize-path": "^3.0.0",
"npm-run-all": "^4.1.3",
"shx": "^0.3.2",
"tslint": "^5.11.0",
"typescript": "^5.4.4"
}
}
32 changes: 32 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Nostrゅう

## これはなに?

伺かのPLUGINです。
Nostrのリレーからイベントを取得してゴーストにSSTPで送信します。
以下に送信しているSSTPの例を挙げます。

```
NOTIFY SSTP/1.1
Charset: UTF-8
SecurityLevel: external
Sender: Node.js
Event: OnNostr
Reference0: Nostr/0.3
Reference1: note(kind)
Reference1: おはノスー!(content)
Reference2: nosuta(name)
Reference3: のす太(display_name)
Reference4: https://example.com/avatar.png(picture)
Option: nobreak
Script: \0おはノスー!\e
```

## 使用モジュール等

- [Node.js](https://nodejs.org/)
- [SHIOLINK](https://github.com/ekicyou/shiori-basic)
- [ShiolinkJS](https://github.com/Narazaka/shiolinkjs)
- [ShioriJK](https://github.com/Narazaka/shiorijk)
- [nostr-tools](https://github.com/nbd-wtf/nostr-tools)
- [ws](https://github.com/websockets/ws)
Loading

0 comments on commit 7c87c72

Please sign in to comment.