This repository has been archived by the owner on Jun 25, 2022. It is now read-only.
generated from haraka/haraka-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- import from Haraka - test: add 3 tests
- Loading branch information
Showing
15 changed files
with
1,924 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
[submodule ".release"] | ||
path = .release | ||
url = git@github.com:msimerson/.release.git | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,58 @@ | ||
.github | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
package-lock.json | ||
bower_components | ||
# Optional npm cache directory | ||
.npmrc | ||
.idea | ||
.DS_Store | ||
haraka-update.sh | ||
|
||
.github | ||
.release | ||
.codeclimate.yml | ||
.editorconfig | ||
.gitignore | ||
.gitmodules | ||
.lgtm.yml | ||
appveyor.yml | ||
codecov.yml | ||
.travis.yml | ||
.eslintrc.yaml | ||
.eslintrc.json | ||
.nyc_output | ||
coverage | ||
.codeclimate.yml | ||
codecov.yml |
Submodule .release
deleted from
20e8e5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,74 @@ | ||
'use strict' | ||
'use strict'; | ||
|
||
exports.register = function () { | ||
this.load_template_ini() | ||
} | ||
const EventEmitter = require('events').EventEmitter; | ||
|
||
class ChunkEmitter extends EventEmitter { | ||
constructor (buffer_size) { | ||
super(); | ||
this.buffer_size = parseInt(buffer_size) || (64 * 1024); | ||
this.buf = null; | ||
this.pos = 0; | ||
this.bufs = []; | ||
this.bufs_size = 0; | ||
} | ||
|
||
fill (input) { | ||
if (typeof input === 'string') { | ||
input = Buffer.from(input); | ||
} | ||
|
||
exports.load_template_ini = function () { | ||
const plugin = this | ||
// Optimization: don't allocate a new buffer until the input we've | ||
// had so far is bigger than our buffer size. | ||
if (!this.buf) { | ||
// We haven't allocated a buffer yet | ||
this.bufs.push(input); | ||
this.bufs_size += input.length; | ||
if ((input.length + this.bufs_size) > this.buffer_size) { | ||
this.buf = Buffer.alloc(this.buffer_size); | ||
const in_new = Buffer.concat(this.bufs, this.bufs_size); | ||
input = in_new; | ||
// Reset | ||
this.bufs = []; | ||
this.bufs_size = 0; | ||
} | ||
else { | ||
return; | ||
} | ||
} | ||
|
||
plugin.cfg = plugin.config.get('template.ini', { | ||
booleans: [ | ||
'+enabled', // plugin.cfg.main.enabled=true | ||
'-disabled', // plugin.cfg.main.disabled=false | ||
'+feature_section.yes' // plugin.cfg.feature_section.yes=true | ||
] | ||
}, | ||
function () { | ||
plugin.load_example_ini() | ||
}) | ||
while (input.length > 0) { | ||
let remaining = this.buffer_size - this.pos; | ||
if (remaining === 0) { | ||
this.emit('data', this.buf); //.slice(0)); | ||
this.buf = Buffer.alloc(this.buffer_size); | ||
this.pos = 0; | ||
remaining = this.buffer_size; | ||
} | ||
const to_write = ((remaining > input.length) ? input.length : remaining); | ||
input.copy(this.buf, this.pos, 0, to_write); | ||
this.pos += to_write; | ||
input = input.slice(to_write); | ||
} | ||
} | ||
|
||
end (cb) { | ||
let emitted = false; | ||
if (this.bufs_size > 0) { | ||
this.emit('data', Buffer.concat(this.bufs, this.bufs_size)); | ||
emitted = true; | ||
} | ||
else if (this.pos > 0) { | ||
this.emit('data', this.buf.slice(0, this.pos)); | ||
emitted = true; | ||
} | ||
// Reset | ||
this.buf = null; | ||
this.pos = 0; | ||
this.bufs = []; | ||
this.bufs_size = 0; | ||
if (cb && typeof cb === 'function') cb(); | ||
return emitted; | ||
} | ||
} | ||
|
||
module.exports = ChunkEmitter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
{ | ||
"name": "haraka-plugin-template", | ||
"version": "1.0.3", | ||
"description": "Haraka plugin that frobnicates email connections", | ||
"name": "haraka-chunk-emitter", | ||
"version": "1.0.0", | ||
"description": "Haraka chunk emitter", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "npx eslint *.js test/*.js", | ||
"lintfix": "npx eslint --fix *.js test/*.js", | ||
"lint": "npx eslint *.js test", | ||
"lintfix": "npx eslint --fix *.js test", | ||
"versions": "npx dependency-version-checker check", | ||
"test": "npx mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/haraka/haraka-plugin-template.git" | ||
"url": "git+https://github.com/haraka/chunk-emitter.git" | ||
}, | ||
"keywords": [ | ||
"haraka", | ||
"plugin", | ||
"template" | ||
"chunk-emitter" | ||
], | ||
"author": "Welcome Member <happy-haraka-hacker@example.com>", | ||
"author": "Haraka Team <haraka.mail@gmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/haraka/haraka-plugin-template/issues" | ||
"url": "https://github.com/haraka/chunk-emitter/issues" | ||
}, | ||
"homepage": "https://github.com/haraka/haraka-plugin-template#readme", | ||
"homepage": "https://github.com/haraka/chunk-emitter#readme", | ||
"devDependencies": { | ||
"eslint": "8", | ||
"eslint-plugin-haraka": "*", | ||
"haraka-test-fixtures": "*", | ||
"mocha": "9" | ||
"eslint": ">=8", | ||
"eslint-plugin-haraka": "*" | ||
} | ||
} |
Oops, something went wrong.